{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "11f31c6b",
   "metadata": {},
   "source": [
    "# 基于streamlit的机器学习应用开发"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a2e50ea3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import streamlit as st \n",
    "import numpy as np \n",
    "import pandas as pd\n",
    "import pickle\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from sklearn.decomposition import PCA\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "from sklearn.ensemble import RandomForestClassifier\n",
    "\n",
    "from sklearn.metrics import accuracy_score,confusion_matrix,f1_score"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63e8bbef",
   "metadata": {},
   "source": [
    "## 机器学习应用的基本流程\n",
    "\n",
    "1.数据导入 2.数据处理 3.选择模型 4.模型拟合 5.学习效果 6. 模型的使用\n",
    "\n",
    "* 请在streamlit中实现如下机器学习流程（参数与模型可选）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4cf1d8af",
   "metadata": {},
   "source": [
    "### 数据导入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8ec8d1ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = datasets.load_iris()\n",
    "#data = datasets.load_wine()\n",
    "#data = datasets.load_breast_cancer()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c73e5431",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[5.1, 3.5, 1.4, 0.2],\n",
       "       [4.9, 3. , 1.4, 0.2],\n",
       "       [4.7, 3.2, 1.3, 0.2],\n",
       "       [4.6, 3.1, 1.5, 0.2],\n",
       "       [5. , 3.6, 1.4, 0.2],\n",
       "       [5.4, 3.9, 1.7, 0.4],\n",
       "       [4.6, 3.4, 1.4, 0.3],\n",
       "       [5. , 3.4, 1.5, 0.2],\n",
       "       [4.4, 2.9, 1.4, 0.2],\n",
       "       [4.9, 3.1, 1.5, 0.1],\n",
       "       [5.4, 3.7, 1.5, 0.2],\n",
       "       [4.8, 3.4, 1.6, 0.2],\n",
       "       [4.8, 3. , 1.4, 0.1],\n",
       "       [4.3, 3. , 1.1, 0.1],\n",
       "       [5.8, 4. , 1.2, 0.2],\n",
       "       [5.7, 4.4, 1.5, 0.4],\n",
       "       [5.4, 3.9, 1.3, 0.4],\n",
       "       [5.1, 3.5, 1.4, 0.3],\n",
       "       [5.7, 3.8, 1.7, 0.3],\n",
       "       [5.1, 3.8, 1.5, 0.3],\n",
       "       [5.4, 3.4, 1.7, 0.2],\n",
       "       [5.1, 3.7, 1.5, 0.4],\n",
       "       [4.6, 3.6, 1. , 0.2],\n",
       "       [5.1, 3.3, 1.7, 0.5],\n",
       "       [4.8, 3.4, 1.9, 0.2],\n",
       "       [5. , 3. , 1.6, 0.2],\n",
       "       [5. , 3.4, 1.6, 0.4],\n",
       "       [5.2, 3.5, 1.5, 0.2],\n",
       "       [5.2, 3.4, 1.4, 0.2],\n",
       "       [4.7, 3.2, 1.6, 0.2],\n",
       "       [4.8, 3.1, 1.6, 0.2],\n",
       "       [5.4, 3.4, 1.5, 0.4],\n",
       "       [5.2, 4.1, 1.5, 0.1],\n",
       "       [5.5, 4.2, 1.4, 0.2],\n",
       "       [4.9, 3.1, 1.5, 0.2],\n",
       "       [5. , 3.2, 1.2, 0.2],\n",
       "       [5.5, 3.5, 1.3, 0.2],\n",
       "       [4.9, 3.6, 1.4, 0.1],\n",
       "       [4.4, 3. , 1.3, 0.2],\n",
       "       [5.1, 3.4, 1.5, 0.2],\n",
       "       [5. , 3.5, 1.3, 0.3],\n",
       "       [4.5, 2.3, 1.3, 0.3],\n",
       "       [4.4, 3.2, 1.3, 0.2],\n",
       "       [5. , 3.5, 1.6, 0.6],\n",
       "       [5.1, 3.8, 1.9, 0.4],\n",
       "       [4.8, 3. , 1.4, 0.3],\n",
       "       [5.1, 3.8, 1.6, 0.2],\n",
       "       [4.6, 3.2, 1.4, 0.2],\n",
       "       [5.3, 3.7, 1.5, 0.2],\n",
       "       [5. , 3.3, 1.4, 0.2],\n",
       "       [7. , 3.2, 4.7, 1.4],\n",
       "       [6.4, 3.2, 4.5, 1.5],\n",
       "       [6.9, 3.1, 4.9, 1.5],\n",
       "       [5.5, 2.3, 4. , 1.3],\n",
       "       [6.5, 2.8, 4.6, 1.5],\n",
       "       [5.7, 2.8, 4.5, 1.3],\n",
       "       [6.3, 3.3, 4.7, 1.6],\n",
       "       [4.9, 2.4, 3.3, 1. ],\n",
       "       [6.6, 2.9, 4.6, 1.3],\n",
       "       [5.2, 2.7, 3.9, 1.4],\n",
       "       [5. , 2. , 3.5, 1. ],\n",
       "       [5.9, 3. , 4.2, 1.5],\n",
       "       [6. , 2.2, 4. , 1. ],\n",
       "       [6.1, 2.9, 4.7, 1.4],\n",
       "       [5.6, 2.9, 3.6, 1.3],\n",
       "       [6.7, 3.1, 4.4, 1.4],\n",
       "       [5.6, 3. , 4.5, 1.5],\n",
       "       [5.8, 2.7, 4.1, 1. ],\n",
       "       [6.2, 2.2, 4.5, 1.5],\n",
       "       [5.6, 2.5, 3.9, 1.1],\n",
       "       [5.9, 3.2, 4.8, 1.8],\n",
       "       [6.1, 2.8, 4. , 1.3],\n",
       "       [6.3, 2.5, 4.9, 1.5],\n",
       "       [6.1, 2.8, 4.7, 1.2],\n",
       "       [6.4, 2.9, 4.3, 1.3],\n",
       "       [6.6, 3. , 4.4, 1.4],\n",
       "       [6.8, 2.8, 4.8, 1.4],\n",
       "       [6.7, 3. , 5. , 1.7],\n",
       "       [6. , 2.9, 4.5, 1.5],\n",
       "       [5.7, 2.6, 3.5, 1. ],\n",
       "       [5.5, 2.4, 3.8, 1.1],\n",
       "       [5.5, 2.4, 3.7, 1. ],\n",
       "       [5.8, 2.7, 3.9, 1.2],\n",
       "       [6. , 2.7, 5.1, 1.6],\n",
       "       [5.4, 3. , 4.5, 1.5],\n",
       "       [6. , 3.4, 4.5, 1.6],\n",
       "       [6.7, 3.1, 4.7, 1.5],\n",
       "       [6.3, 2.3, 4.4, 1.3],\n",
       "       [5.6, 3. , 4.1, 1.3],\n",
       "       [5.5, 2.5, 4. , 1.3],\n",
       "       [5.5, 2.6, 4.4, 1.2],\n",
       "       [6.1, 3. , 4.6, 1.4],\n",
       "       [5.8, 2.6, 4. , 1.2],\n",
       "       [5. , 2.3, 3.3, 1. ],\n",
       "       [5.6, 2.7, 4.2, 1.3],\n",
       "       [5.7, 3. , 4.2, 1.2],\n",
       "       [5.7, 2.9, 4.2, 1.3],\n",
       "       [6.2, 2.9, 4.3, 1.3],\n",
       "       [5.1, 2.5, 3. , 1.1],\n",
       "       [5.7, 2.8, 4.1, 1.3],\n",
       "       [6.3, 3.3, 6. , 2.5],\n",
       "       [5.8, 2.7, 5.1, 1.9],\n",
       "       [7.1, 3. , 5.9, 2.1],\n",
       "       [6.3, 2.9, 5.6, 1.8],\n",
       "       [6.5, 3. , 5.8, 2.2],\n",
       "       [7.6, 3. , 6.6, 2.1],\n",
       "       [4.9, 2.5, 4.5, 1.7],\n",
       "       [7.3, 2.9, 6.3, 1.8],\n",
       "       [6.7, 2.5, 5.8, 1.8],\n",
       "       [7.2, 3.6, 6.1, 2.5],\n",
       "       [6.5, 3.2, 5.1, 2. ],\n",
       "       [6.4, 2.7, 5.3, 1.9],\n",
       "       [6.8, 3. , 5.5, 2.1],\n",
       "       [5.7, 2.5, 5. , 2. ],\n",
       "       [5.8, 2.8, 5.1, 2.4],\n",
       "       [6.4, 3.2, 5.3, 2.3],\n",
       "       [6.5, 3. , 5.5, 1.8],\n",
       "       [7.7, 3.8, 6.7, 2.2],\n",
       "       [7.7, 2.6, 6.9, 2.3],\n",
       "       [6. , 2.2, 5. , 1.5],\n",
       "       [6.9, 3.2, 5.7, 2.3],\n",
       "       [5.6, 2.8, 4.9, 2. ],\n",
       "       [7.7, 2.8, 6.7, 2. ],\n",
       "       [6.3, 2.7, 4.9, 1.8],\n",
       "       [6.7, 3.3, 5.7, 2.1],\n",
       "       [7.2, 3.2, 6. , 1.8],\n",
       "       [6.2, 2.8, 4.8, 1.8],\n",
       "       [6.1, 3. , 4.9, 1.8],\n",
       "       [6.4, 2.8, 5.6, 2.1],\n",
       "       [7.2, 3. , 5.8, 1.6],\n",
       "       [7.4, 2.8, 6.1, 1.9],\n",
       "       [7.9, 3.8, 6.4, 2. ],\n",
       "       [6.4, 2.8, 5.6, 2.2],\n",
       "       [6.3, 2.8, 5.1, 1.5],\n",
       "       [6.1, 2.6, 5.6, 1.4],\n",
       "       [7.7, 3. , 6.1, 2.3],\n",
       "       [6.3, 3.4, 5.6, 2.4],\n",
       "       [6.4, 3.1, 5.5, 1.8],\n",
       "       [6. , 3. , 4.8, 1.8],\n",
       "       [6.9, 3.1, 5.4, 2.1],\n",
       "       [6.7, 3.1, 5.6, 2.4],\n",
       "       [6.9, 3.1, 5.1, 2.3],\n",
       "       [5.8, 2.7, 5.1, 1.9],\n",
       "       [6.8, 3.2, 5.9, 2.3],\n",
       "       [6.7, 3.3, 5.7, 2.5],\n",
       "       [6.7, 3. , 5.2, 2.3],\n",
       "       [6.3, 2.5, 5. , 1.9],\n",
       "       [6.5, 3. , 5.2, 2. ],\n",
       "       [6.2, 3.4, 5.4, 2.3],\n",
       "       [5.9, 3. , 5.1, 1.8]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "358b8d19",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.target"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "af7a14e3",
   "metadata": {},
   "source": [
    "### 数据分析与处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "0c26d282",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_data=pd.DataFrame(data.data,columns=data.feature_names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "52e2bb69",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_target=pd.Series(data.target)\n",
    "df_target.name=\"class\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "7515a7fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length (cm)</th>\n",
       "      <th>sepal width (cm)</th>\n",
       "      <th>petal length (cm)</th>\n",
       "      <th>petal width (cm)</th>\n",
       "      <th>class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.5</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>6.5</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>6.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>5.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.8</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)  \\\n",
       "0                  5.1               3.5                1.4               0.2   \n",
       "1                  4.9               3.0                1.4               0.2   \n",
       "2                  4.7               3.2                1.3               0.2   \n",
       "3                  4.6               3.1                1.5               0.2   \n",
       "4                  5.0               3.6                1.4               0.2   \n",
       "..                 ...               ...                ...               ...   \n",
       "145                6.7               3.0                5.2               2.3   \n",
       "146                6.3               2.5                5.0               1.9   \n",
       "147                6.5               3.0                5.2               2.0   \n",
       "148                6.2               3.4                5.4               2.3   \n",
       "149                5.9               3.0                5.1               1.8   \n",
       "\n",
       "     class  \n",
       "0        0  \n",
       "1        0  \n",
       "2        0  \n",
       "3        0  \n",
       "4        0  \n",
       "..     ...  \n",
       "145      2  \n",
       "146      2  \n",
       "147      2  \n",
       "148      2  \n",
       "149      2  \n",
       "\n",
       "[150 rows x 5 columns]"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([df_data,df_target],axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "d7743d7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "#data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "abad7588",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'data' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [13]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[43mdata\u001b[49m\u001b[38;5;241m.\u001b[39mdata\n\u001b[0;32m      2\u001b[0m y \u001b[38;5;241m=\u001b[39m data\u001b[38;5;241m.\u001b[39mtarget\n",
      "\u001b[1;31mNameError\u001b[0m: name 'data' is not defined"
     ]
    }
   ],
   "source": [
    "x = data.data\n",
    "y = data.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cd982e8e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, ..., 0, 0, 0], dtype=int64)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a16cde52",
   "metadata": {},
   "source": [
    "### 模型的拟合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "d77f6737",
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3)\n",
    "                                                    #, random_state=1234)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "6494a9b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "model=RandomForestClassifier(n_estimators=50,max_depth=3, random_state=1234)\n",
    "#model=SVC(C=2)\n",
    "#model = KNeighborsClassifier(n_neighbors=4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "47feab49",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RandomForestClassifier(max_depth=3, n_estimators=50, random_state=1234)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "a6f8f906",
   "metadata": {},
   "outputs": [],
   "source": [
    "#X_test"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9990ec32",
   "metadata": {},
   "source": [
    "### 模型的验证"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "4da56b39",
   "metadata": {},
   "outputs": [],
   "source": [
    "y_pred = model.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "66ea66f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "acc = accuracy_score(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "bb24cb88",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[2986,    0],\n",
       "       [   4,    7]], dtype=int64)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "confusion_matrix(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "3c3f40ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7777777777777778"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f1_score(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4e41590c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9994994994994995"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "acc"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "43a869a1",
   "metadata": {},
   "source": [
    "### 模型的使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "ff920dc8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0])"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict([[4.8, 3.4, 1.6, 0.2]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "573b6380",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.06728234, 0.01665775, 0.48895537, 0.42710455])"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.feature_importances_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "688a3fd8",
   "metadata": {},
   "outputs": [],
   "source": [
    "#enc.fit(pd[\"Technology\"].values)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "98cfa76c",
   "metadata": {},
   "source": [
    "## 精准营销应用搭建\n",
    "\n",
    "* 定向营销\n",
    "\n",
    "根据过去对目标营销活动的响应创建客户响应模型，以预测可能响应的客户并提高新活动的转化率。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "111c8abc",
   "metadata": {},
   "source": [
    "### 数据导入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d003b46e",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_csv(r\"F:\\notebooks1\\streamlit\\data\\old.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "177f5cec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Area</th>\n",
       "      <th>Email</th>\n",
       "      <th>Mobile</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "      <th>Response</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>COX</td>\n",
       "      <td>64</td>\n",
       "      <td>female</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>never</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>FARLEY</td>\n",
       "      <td>49</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>premium</td>\n",
       "      <td>never</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HYDE</td>\n",
       "      <td>63</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>never</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>SANTIAGO</td>\n",
       "      <td>75</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>premium</td>\n",
       "      <td>yes</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>COPELAND</td>\n",
       "      <td>37</td>\n",
       "      <td>female</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>yes</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>62</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Name  Age  Gender   Area    Email Mobile  Logins 4 weeks  \\\n",
       "0       COX   64  female  urban     free  never               1   \n",
       "1    FARLEY   49    male  urban  premium  never               0   \n",
       "2      HYDE   63    male  urban     free  never               0   \n",
       "3  SANTIAGO   75    male  urban  premium    yes               0   \n",
       "4  COPELAND   37  female  urban     free    yes               0   \n",
       "\n",
       "   Logins 6 months  Sales 4 weeks  Sales 6 months  Sales total Response  \n",
       "0                1              0               0            0       no  \n",
       "1                4              0               0            0      yes  \n",
       "2                0              0               0            0       no  \n",
       "3                0              0               0            0      yes  \n",
       "4                0              0               0           62       no  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#从过去的营销活动中加载和准备数据，包括接收者属性（例如年龄、性别、地区）和行为属性（产品和服务的使用、网站等）。\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04d42434",
   "metadata": {},
   "source": [
    "### 数据分析与处理\n",
    "\n",
    "https://blog.csdn.net/qq_55342245/article/details/121673329\n",
    "\n",
    "### classwork 2\n",
    "\n",
    "1. 完成数据的读入\n",
    "2. 完成数据的处理，得到特征矩阵x与目标向量y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "679a087a",
   "metadata": {},
   "outputs": [],
   "source": [
    "df[\"Response\"]=df[\"Response\"].map({\"no\":0,\"yes\":1})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c50b723f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.drop(axis=1,columns=\"Name\",inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9a2a52af",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Area</th>\n",
       "      <th>Email</th>\n",
       "      <th>Mobile</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "      <th>Response</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>64</td>\n",
       "      <td>female</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>never</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>49</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>premium</td>\n",
       "      <td>never</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>63</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>never</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>75</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>premium</td>\n",
       "      <td>yes</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>37</td>\n",
       "      <td>female</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>yes</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>62</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Age  Gender   Area    Email Mobile  Logins 4 weeks  Logins 6 months  \\\n",
       "0   64  female  urban     free  never               1                1   \n",
       "1   49    male  urban  premium  never               0                4   \n",
       "2   63    male  urban     free  never               0                0   \n",
       "3   75    male  urban  premium    yes               0                0   \n",
       "4   37  female  urban     free    yes               0                0   \n",
       "\n",
       "   Sales 4 weeks  Sales 6 months  Sales total  Response  \n",
       "0              0               0            0         0  \n",
       "1              0               0            0         1  \n",
       "2              0               0            0         0  \n",
       "3              0               0            0         1  \n",
       "4              0               0           62         0  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "bebd18dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   a  b  c  d\n",
      "0  1  0  0  0\n",
      "1  0  1  0  0\n",
      "2  0  0  1  0\n",
      "3  0  0  0  1\n"
     ]
    }
   ],
   "source": [
    "s=pd.Series(list('abcd'))\n",
    "s_=pd.get_dummies(s)\n",
    "print(s_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "946deca6",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_0=pd.get_dummies(df,columns=[\"Gender\",\"Area\",\"Email\",\"Mobile\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3c0e2385",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "      <th>Response</th>\n",
       "      <th>Gender_female</th>\n",
       "      <th>Gender_male</th>\n",
       "      <th>Area_rural</th>\n",
       "      <th>Area_urban</th>\n",
       "      <th>Email_free</th>\n",
       "      <th>Email_premium</th>\n",
       "      <th>Mobile_always</th>\n",
       "      <th>Mobile_never</th>\n",
       "      <th>Mobile_yes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>64</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>49</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>75</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>37</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>62</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Age  Logins 4 weeks  Logins 6 months  Sales 4 weeks  Sales 6 months  \\\n",
       "0   64               1                1              0               0   \n",
       "1   49               0                4              0               0   \n",
       "2   63               0                0              0               0   \n",
       "3   75               0                0              0               0   \n",
       "4   37               0                0              0               0   \n",
       "\n",
       "   Sales total  Response  Gender_female  Gender_male  Area_rural  Area_urban  \\\n",
       "0            0         0              1            0           0           1   \n",
       "1            0         1              0            1           0           1   \n",
       "2            0         0              0            1           0           1   \n",
       "3            0         1              0            1           0           1   \n",
       "4           62         0              1            0           0           1   \n",
       "\n",
       "   Email_free  Email_premium  Mobile_always  Mobile_never  Mobile_yes  \n",
       "0           1              0              0             1           0  \n",
       "1           0              1              0             1           0  \n",
       "2           1              0              0             1           0  \n",
       "3           0              1              0             0           1  \n",
       "4           1              0              0             0           1  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_0.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f9c7f92a",
   "metadata": {},
   "outputs": [],
   "source": [
    "y=df_0[\"Response\"].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1ddef6da",
   "metadata": {},
   "outputs": [],
   "source": [
    "x=df_0.drop(axis=1,columns=\"Response\").values"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f822c698",
   "metadata": {},
   "source": [
    "### 模型的拟合与验证"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0ef3c15a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7172413793103448"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n",
    "model=RandomForestClassifier(n_estimators=10,max_depth=2, random_state=1234)\n",
    "model.fit(X_train, y_train)\n",
    "y_pred = model.predict(X_test)\n",
    "f1_score(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81d582a7",
   "metadata": {},
   "source": [
    "### 模型的使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "95946ecd",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_new=pd.read_csv(r\"F:\\notebooks1\\streamlit\\data\\new.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ed6ca33f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_new.drop(axis=1,columns=\"Name\",inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3526ebbe",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_new=pd.get_dummies(df_new,columns=[\"Gender\",\"Area\",\"Email\",\"Mobile\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "5b91e0ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "      <th>Gender_female</th>\n",
       "      <th>Gender_male</th>\n",
       "      <th>Area_rural</th>\n",
       "      <th>Area_urban</th>\n",
       "      <th>Email_free</th>\n",
       "      <th>Email_premium</th>\n",
       "      <th>Mobile_always</th>\n",
       "      <th>Mobile_never</th>\n",
       "      <th>Mobile_yes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>88</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>25</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Age  Logins 4 weeks  Logins 6 months  Sales 4 weeks  Sales 6 months  \\\n",
       "0   54               0                7              0               0   \n",
       "1   88               3                3              0               0   \n",
       "2   31               0                7              0               0   \n",
       "3   54               0                0              0               0   \n",
       "4   25               0                0              0               0   \n",
       "\n",
       "   Sales total  Gender_female  Gender_male  Area_rural  Area_urban  \\\n",
       "0            0              1            0           1           0   \n",
       "1            0              0            1           0           1   \n",
       "2            0              1            0           0           1   \n",
       "3            0              1            0           1           0   \n",
       "4            0              0            1           0           1   \n",
       "\n",
       "   Email_free  Email_premium  Mobile_always  Mobile_never  Mobile_yes  \n",
       "0           1              0              1             0           0  \n",
       "1           1              0              0             1           0  \n",
       "2           1              0              1             0           0  \n",
       "3           1              0              0             1           0  \n",
       "4           1              0              0             1           0  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_new.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "37a03a20",
   "metadata": {},
   "outputs": [],
   "source": [
    "y_pred = model.predict(df_new.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "13a5242c",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_new[\"predict\"]=y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b3558783",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "      <th>Gender_female</th>\n",
       "      <th>Gender_male</th>\n",
       "      <th>Area_rural</th>\n",
       "      <th>Area_urban</th>\n",
       "      <th>Email_free</th>\n",
       "      <th>Email_premium</th>\n",
       "      <th>Mobile_always</th>\n",
       "      <th>Mobile_never</th>\n",
       "      <th>Mobile_yes</th>\n",
       "      <th>predict</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>88</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>25</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>51</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>35</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>46</td>\n",
       "      <td>131</td>\n",
       "      <td>131</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>81</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>366</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>27</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>19</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Age  Logins 4 weeks  Logins 6 months  Sales 4 weeks  Sales 6 months  \\\n",
       "0     54               0                7              0               0   \n",
       "1     88               3                3              0               0   \n",
       "2     31               0                7              0               0   \n",
       "3     54               0                0              0               0   \n",
       "4     25               0                0              0               0   \n",
       "..   ...             ...              ...            ...             ...   \n",
       "995   51               5                5              0               0   \n",
       "996   35               3               10             46             131   \n",
       "997   81               0                0              0               0   \n",
       "998   27               9                9              0               0   \n",
       "999   19               2                2              0               0   \n",
       "\n",
       "     Sales total  Gender_female  Gender_male  Area_rural  Area_urban  \\\n",
       "0              0              1            0           1           0   \n",
       "1              0              0            1           0           1   \n",
       "2              0              1            0           0           1   \n",
       "3              0              1            0           1           0   \n",
       "4              0              0            1           0           1   \n",
       "..           ...            ...          ...         ...         ...   \n",
       "995            0              1            0           0           1   \n",
       "996          131              0            1           0           1   \n",
       "997          366              1            0           1           0   \n",
       "998            0              0            1           1           0   \n",
       "999            0              0            1           1           0   \n",
       "\n",
       "     Email_free  Email_premium  Mobile_always  Mobile_never  Mobile_yes  \\\n",
       "0             1              0              1             0           0   \n",
       "1             1              0              0             1           0   \n",
       "2             1              0              1             0           0   \n",
       "3             1              0              0             1           0   \n",
       "4             1              0              0             1           0   \n",
       "..          ...            ...            ...           ...         ...   \n",
       "995           1              0              0             1           0   \n",
       "996           1              0              0             1           0   \n",
       "997           1              0              0             1           0   \n",
       "998           1              0              0             1           0   \n",
       "999           1              0              1             0           0   \n",
       "\n",
       "     predict  \n",
       "0          0  \n",
       "1          0  \n",
       "2          0  \n",
       "3          0  \n",
       "4          0  \n",
       "..       ...  \n",
       "995        0  \n",
       "996        1  \n",
       "997        0  \n",
       "998        1  \n",
       "999        0  \n",
       "\n",
       "[1000 rows x 16 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "8163976e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on Styler in module pandas.io.formats.style object:\n",
      "\n",
      "class Styler(pandas.io.formats.style_render.StylerRenderer)\n",
      " |  Styler(data: 'DataFrame | Series', precision: 'int | None' = None, table_styles: 'CSSStyles | None' = None, uuid: 'str | None' = None, caption: 'str | tuple | None' = None, table_attributes: 'str | None' = None, cell_ids: 'bool' = True, na_rep: 'str | None' = None, uuid_len: 'int' = 5, decimal: 'str | None' = None, thousands: 'str | None' = None, escape: 'str | None' = None, formatter: 'ExtFormatter | None' = None)\n",
      " |  \n",
      " |  Helps style a DataFrame or Series according to the data with HTML and CSS.\n",
      " |  \n",
      " |  Parameters\n",
      " |  ----------\n",
      " |  data : Series or DataFrame\n",
      " |      Data to be styled - either a Series or DataFrame.\n",
      " |  precision : int, optional\n",
      " |      Precision to round floats to. If not given defaults to\n",
      " |      ``pandas.options.styler.format.precision``.\n",
      " |  \n",
      " |      .. versionchanged:: 1.4.0\n",
      " |  table_styles : list-like, default None\n",
      " |      List of {selector: (attr, value)} dicts; see Notes.\n",
      " |  uuid : str, default None\n",
      " |      A unique identifier to avoid CSS collisions; generated automatically.\n",
      " |  caption : str, tuple, default None\n",
      " |      String caption to attach to the table. Tuple only used for LaTeX dual captions.\n",
      " |  table_attributes : str, default None\n",
      " |      Items that show up in the opening ``<table>`` tag\n",
      " |      in addition to automatic (by default) id.\n",
      " |  cell_ids : bool, default True\n",
      " |      If True, each cell will have an ``id`` attribute in their HTML tag.\n",
      " |      The ``id`` takes the form ``T_<uuid>_row<num_row>_col<num_col>``\n",
      " |      where ``<uuid>`` is the unique identifier, ``<num_row>`` is the row\n",
      " |      number and ``<num_col>`` is the column number.\n",
      " |  na_rep : str, optional\n",
      " |      Representation for missing values.\n",
      " |      If ``na_rep`` is None, no special formatting is applied, and falls back to\n",
      " |      ``pandas.options.styler.format.na_rep``.\n",
      " |  \n",
      " |      .. versionadded:: 1.0.0\n",
      " |  \n",
      " |  uuid_len : int, default 5\n",
      " |      If ``uuid`` is not specified, the length of the ``uuid`` to randomly generate\n",
      " |      expressed in hex characters, in range [0, 32].\n",
      " |  \n",
      " |      .. versionadded:: 1.2.0\n",
      " |  \n",
      " |  decimal : str, optional\n",
      " |      Character used as decimal separator for floats, complex and integers. If not\n",
      " |      given uses ``pandas.options.styler.format.decimal``.\n",
      " |  \n",
      " |      .. versionadded:: 1.3.0\n",
      " |  \n",
      " |  thousands : str, optional, default None\n",
      " |      Character used as thousands separator for floats, complex and integers. If not\n",
      " |      given uses ``pandas.options.styler.format.thousands``.\n",
      " |  \n",
      " |      .. versionadded:: 1.3.0\n",
      " |  \n",
      " |  escape : str, optional\n",
      " |      Use 'html' to replace the characters ``&``, ``<``, ``>``, ``'``, and ``\"``\n",
      " |      in cell display string with HTML-safe sequences.\n",
      " |      Use 'latex' to replace the characters ``&``, ``%``, ``$``, ``#``, ``_``,\n",
      " |      ``{``, ``}``, ``~``, ``^``, and ``\\`` in the cell display string with\n",
      " |      LaTeX-safe sequences. If not given uses ``pandas.options.styler.format.escape``.\n",
      " |  \n",
      " |      .. versionadded:: 1.3.0\n",
      " |  formatter : str, callable, dict, optional\n",
      " |      Object to define how values are displayed. See ``Styler.format``. If not given\n",
      " |      uses ``pandas.options.styler.format.formatter``.\n",
      " |  \n",
      " |      .. versionadded:: 1.4.0\n",
      " |  \n",
      " |  Attributes\n",
      " |  ----------\n",
      " |  env : Jinja2 jinja2.Environment\n",
      " |  template_html : Jinja2 Template\n",
      " |  template_html_table : Jinja2 Template\n",
      " |  template_html_style : Jinja2 Template\n",
      " |  template_latex : Jinja2 Template\n",
      " |  loader : Jinja2 Loader\n",
      " |  \n",
      " |  See Also\n",
      " |  --------\n",
      " |  DataFrame.style : Return a Styler object containing methods for building\n",
      " |      a styled HTML representation for the DataFrame.\n",
      " |  \n",
      " |  Notes\n",
      " |  -----\n",
      " |  Most styling will be done by passing style functions into\n",
      " |  ``Styler.apply`` or ``Styler.applymap``. Style functions should\n",
      " |  return values with strings containing CSS ``'attr: value'`` that will\n",
      " |  be applied to the indicated cells.\n",
      " |  \n",
      " |  If using in the Jupyter notebook, Styler has defined a ``_repr_html_``\n",
      " |  to automatically render itself. Otherwise call Styler.to_html to get\n",
      " |  the generated HTML.\n",
      " |  \n",
      " |  CSS classes are attached to the generated HTML\n",
      " |  \n",
      " |  * Index and Column names include ``index_name`` and ``level<k>``\n",
      " |    where `k` is its level in a MultiIndex\n",
      " |  * Index label cells include\n",
      " |  \n",
      " |    * ``row_heading``\n",
      " |    * ``row<n>`` where `n` is the numeric position of the row\n",
      " |    * ``level<k>`` where `k` is the level in a MultiIndex\n",
      " |  \n",
      " |  * Column label cells include\n",
      " |    * ``col_heading``\n",
      " |    * ``col<n>`` where `n` is the numeric position of the column\n",
      " |    * ``level<k>`` where `k` is the level in a MultiIndex\n",
      " |  \n",
      " |  * Blank cells include ``blank``\n",
      " |  * Data cells include ``data``\n",
      " |  * Trimmed cells include ``col_trim`` or ``row_trim``.\n",
      " |  \n",
      " |  Any, or all, or these classes can be renamed by using the ``css_class_names``\n",
      " |  argument in ``Styler.set_table_classes``, giving a value such as\n",
      " |  *{\"row\": \"MY_ROW_CLASS\", \"col_trim\": \"\", \"row_trim\": \"\"}*.\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      Styler\n",
      " |      pandas.io.formats.style_render.StylerRenderer\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __copy__(self) -> 'Styler'\n",
      " |  \n",
      " |  __deepcopy__(self, memo) -> 'Styler'\n",
      " |  \n",
      " |  __init__(self, data: 'DataFrame | Series', precision: 'int | None' = None, table_styles: 'CSSStyles | None' = None, uuid: 'str | None' = None, caption: 'str | tuple | None' = None, table_attributes: 'str | None' = None, cell_ids: 'bool' = True, na_rep: 'str | None' = None, uuid_len: 'int' = 5, decimal: 'str | None' = None, thousands: 'str | None' = None, escape: 'str | None' = None, formatter: 'ExtFormatter | None' = None)\n",
      " |      Initialize self.  See help(type(self)) for accurate signature.\n",
      " |  \n",
      " |  apply(self, func: 'Callable', axis: 'Axis | None' = 0, subset: 'Subset | None' = None, **kwargs) -> 'Styler'\n",
      " |      Apply a CSS-styling function column-wise, row-wise, or table-wise.\n",
      " |      \n",
      " |      Updates the HTML representation with the result.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      func : function\n",
      " |          ``func`` should take a Series if ``axis`` in [0,1] and return a list-like\n",
      " |          object of same length, or a Series, not necessarily of same length, with\n",
      " |          valid index labels considering ``subset``.\n",
      " |          ``func`` should take a DataFrame if ``axis`` is ``None`` and return either\n",
      " |          an ndarray with the same shape or a DataFrame, not necessarily of the same\n",
      " |          shape, with valid index and columns labels considering ``subset``.\n",
      " |      \n",
      " |          .. versionchanged:: 1.3.0\n",
      " |      \n",
      " |          .. versionchanged:: 1.4.0\n",
      " |      \n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``), or to the entire DataFrame at once\n",
      " |          with ``axis=None``.\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      **kwargs : dict\n",
      " |          Pass along to ``func``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.applymap_index: Apply a CSS-styling function to headers elementwise.\n",
      " |      Styler.apply_index: Apply a CSS-styling function to headers level-wise.\n",
      " |      Styler.applymap: Apply a CSS-styling function elementwise.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      The elements of the output of ``func`` should be CSS styles as strings, in the\n",
      " |      format 'attribute: value; attribute2: value2; ...' or,\n",
      " |      if nothing is to be applied to that element, an empty string or ``None``.\n",
      " |      \n",
      " |      This is similar to ``DataFrame.apply``, except that ``axis=None``\n",
      " |      applies the function to the entire DataFrame at once,\n",
      " |      rather than column-wise or row-wise.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> def highlight_max(x, color):\n",
      " |      ...     return np.where(x == np.nanmax(x.to_numpy()), f\"color: {color};\", None)\n",
      " |      >>> df = pd.DataFrame(np.random.randn(5, 2), columns=[\"A\", \"B\"])\n",
      " |      >>> df.style.apply(highlight_max, color='red')  # doctest: +SKIP\n",
      " |      >>> df.style.apply(highlight_max, color='blue', axis=1)  # doctest: +SKIP\n",
      " |      >>> df.style.apply(highlight_max, color='green', axis=None)  # doctest: +SKIP\n",
      " |      \n",
      " |      Using ``subset`` to restrict application to a single column or multiple columns\n",
      " |      \n",
      " |      >>> df.style.apply(highlight_max, color='red', subset=\"A\")\n",
      " |      ...  # doctest: +SKIP\n",
      " |      >>> df.style.apply(highlight_max, color='red', subset=[\"A\", \"B\"])\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      Using a 2d input to ``subset`` to select rows in addition to columns\n",
      " |      \n",
      " |      >>> df.style.apply(highlight_max, color='red', subset=([0,1,2], slice(None)))\n",
      " |      ...  # doctest: +SKIP\n",
      " |      >>> df.style.apply(highlight_max, color='red', subset=(slice(0,5,2), \"A\"))\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      Using a function which returns a Series / DataFrame of unequal length but\n",
      " |      containing valid index labels\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2], [3, 4], [4, 6]], index=[\"A1\", \"A2\", \"Total\"])\n",
      " |      >>> total_style = pd.Series(\"font-weight: bold;\", index=[\"Total\"])\n",
      " |      >>> df.style.apply(lambda s: total_style)  # doctest: +SKIP\n",
      " |      \n",
      " |      See `Table Visualization <../../user_guide/style.ipynb>`_ user guide for\n",
      " |      more details.\n",
      " |  \n",
      " |  apply_index(self, func: 'Callable', axis: 'int | str' = 0, level: 'Level | list[Level] | None' = None, **kwargs) -> 'Styler'\n",
      " |      Apply a CSS-styling function to the index or column headers, level-wise.\n",
      " |      \n",
      " |      Updates the HTML representation with the result.\n",
      " |      \n",
      " |      .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      func : function\n",
      " |          ``func`` should take a Series and return a string array of the same length.\n",
      " |      axis : {0, 1, \"index\", \"columns\"}\n",
      " |          The headers over which to apply the function.\n",
      " |      level : int, str, list, optional\n",
      " |          If index is MultiIndex the level(s) over which to apply the function.\n",
      " |      **kwargs : dict\n",
      " |          Pass along to ``func``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.applymap_index: Apply a CSS-styling function to headers elementwise.\n",
      " |      Styler.apply: Apply a CSS-styling function column-wise, row-wise, or table-wise.\n",
      " |      Styler.applymap: Apply a CSS-styling function elementwise.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      Each input to ``func`` will be the index as a Series, if an Index, or a level of a MultiIndex. The output of ``func`` should be\n",
      " |      an identically sized array of CSS styles as strings, in the format 'attribute: value; attribute2: value2; ...'\n",
      " |      or, if nothing is to be applied to that element, an empty string or ``None``.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Basic usage to conditionally highlight values in the index.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1,2], [3,4]], index=[\"A\", \"B\"])\n",
      " |      >>> def color_b(s):\n",
      " |      ...     return np.where(s == \"B\", \"background-color: yellow;\", \"\")\n",
      " |      >>> df.style.apply_index(color_b)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/appmaphead1.png\n",
      " |      \n",
      " |      Selectively applying to specific levels of MultiIndex columns.\n",
      " |      \n",
      " |      >>> midx = pd.MultiIndex.from_product([['ix', 'jy'], [0, 1], ['x3', 'z4']])\n",
      " |      >>> df = pd.DataFrame([np.arange(8)], columns=midx)\n",
      " |      >>> def highlight_x(s):\n",
      " |      ...     return [\"background-color: yellow;\" if \"x\" in v else \"\" for v in s]\n",
      " |      >>> df.style.apply_index(highlight_x, axis=\"columns\", level=[0, 2])\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/appmaphead2.png\n",
      " |  \n",
      " |  applymap(self, func: 'Callable', subset: 'Subset | None' = None, **kwargs) -> 'Styler'\n",
      " |      Apply a CSS-styling function elementwise.\n",
      " |      \n",
      " |      Updates the HTML representation with the result.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      func : function\n",
      " |          ``func`` should take a scalar and return a string.\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      **kwargs : dict\n",
      " |          Pass along to ``func``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.applymap_index: Apply a CSS-styling function to headers elementwise.\n",
      " |      Styler.apply_index: Apply a CSS-styling function to headers level-wise.\n",
      " |      Styler.apply: Apply a CSS-styling function column-wise, row-wise, or table-wise.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      The elements of the output of ``func`` should be CSS styles as strings, in the\n",
      " |      format 'attribute: value; attribute2: value2; ...' or,\n",
      " |      if nothing is to be applied to that element, an empty string or ``None``.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> def color_negative(v, color):\n",
      " |      ...     return f\"color: {color};\" if v < 0 else None\n",
      " |      >>> df = pd.DataFrame(np.random.randn(5, 2), columns=[\"A\", \"B\"])\n",
      " |      >>> df.style.applymap(color_negative, color='red')  # doctest: +SKIP\n",
      " |      \n",
      " |      Using ``subset`` to restrict application to a single column or multiple columns\n",
      " |      \n",
      " |      >>> df.style.applymap(color_negative, color='red', subset=\"A\")\n",
      " |      ...  # doctest: +SKIP\n",
      " |      >>> df.style.applymap(color_negative, color='red', subset=[\"A\", \"B\"])\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      Using a 2d input to ``subset`` to select rows in addition to columns\n",
      " |      \n",
      " |      >>> df.style.applymap(color_negative, color='red',\n",
      " |      ...  subset=([0,1,2], slice(None)))  # doctest: +SKIP\n",
      " |      >>> df.style.applymap(color_negative, color='red', subset=(slice(0,5,2), \"A\"))\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      See `Table Visualization <../../user_guide/style.ipynb>`_ user guide for\n",
      " |      more details.\n",
      " |  \n",
      " |  applymap_index(self, func: 'Callable', axis: 'int | str' = 0, level: 'Level | list[Level] | None' = None, **kwargs) -> 'Styler'\n",
      " |      Apply a CSS-styling function to the index or column headers, elementwise.\n",
      " |      \n",
      " |      Updates the HTML representation with the result.\n",
      " |      \n",
      " |      .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      func : function\n",
      " |          ``func`` should take a scalar and return a string.\n",
      " |      axis : {0, 1, \"index\", \"columns\"}\n",
      " |          The headers over which to apply the function.\n",
      " |      level : int, str, list, optional\n",
      " |          If index is MultiIndex the level(s) over which to apply the function.\n",
      " |      **kwargs : dict\n",
      " |          Pass along to ``func``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.apply_index: Apply a CSS-styling function to headers level-wise.\n",
      " |      Styler.apply: Apply a CSS-styling function column-wise, row-wise, or table-wise.\n",
      " |      Styler.applymap: Apply a CSS-styling function elementwise.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      Each input to ``func`` will be an index value, if an Index, or a level value of a MultiIndex. The output of ``func`` should be\n",
      " |      CSS styles as a string, in the format 'attribute: value; attribute2: value2; ...'\n",
      " |      or, if nothing is to be applied to that element, an empty string or ``None``.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Basic usage to conditionally highlight values in the index.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1,2], [3,4]], index=[\"A\", \"B\"])\n",
      " |      >>> def color_b(s):\n",
      " |      ...     return \"background-color: yellow;\" if v == \"B\" else None\n",
      " |      >>> df.style.applymap_index(color_b)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/appmaphead1.png\n",
      " |      \n",
      " |      Selectively applying to specific levels of MultiIndex columns.\n",
      " |      \n",
      " |      >>> midx = pd.MultiIndex.from_product([['ix', 'jy'], [0, 1], ['x3', 'z4']])\n",
      " |      >>> df = pd.DataFrame([np.arange(8)], columns=midx)\n",
      " |      >>> def highlight_x(v):\n",
      " |      ...     return \"background-color: yellow;\" if \"x\" in v else None\n",
      " |      >>> df.style.applymap_index(highlight_x, axis=\"columns\", level=[0, 2])\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/appmaphead2.png\n",
      " |  \n",
      " |  background_gradient(self, cmap='PuBu', low: 'float' = 0, high: 'float' = 0, axis: 'Axis | None' = 0, subset: 'Subset | None' = None, text_color_threshold: 'float' = 0.408, vmin: 'float | None' = None, vmax: 'float | None' = None, gmap: 'Sequence | None' = None) -> 'Styler'\n",
      " |      Color the background in a gradient style.\n",
      " |      \n",
      " |      The background color is determined according\n",
      " |      to the data in each column, row or frame, or by a given\n",
      " |      gradient map. Requires matplotlib.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      cmap : str or colormap\n",
      " |          Matplotlib colormap.\n",
      " |      low : float\n",
      " |          Compress the color range at the low end. This is a multiple of the data\n",
      " |          range to extend below the minimum; good values usually in [0, 1],\n",
      " |          defaults to 0.\n",
      " |      high : float\n",
      " |          Compress the color range at the high end. This is a multiple of the data\n",
      " |          range to extend above the maximum; good values usually in [0, 1],\n",
      " |          defaults to 0.\n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``), or to the entire DataFrame at once\n",
      " |          with ``axis=None``.\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      text_color_threshold : float or int\n",
      " |          \n",
      " |          Luminance threshold for determining text color in [0, 1]. Facilitates text\n",
      " |          visibility across varying background colors. All text is dark if 0, and\n",
      " |          light if 1, defaults to 0.408.\n",
      " |      vmin : float, optional\n",
      " |          Minimum data value that corresponds to colormap minimum value.\n",
      " |          If not specified the minimum value of the data (or gmap) will be used.\n",
      " |      \n",
      " |          .. versionadded:: 1.0.0\n",
      " |      \n",
      " |      vmax : float, optional\n",
      " |          Maximum data value that corresponds to colormap maximum value.\n",
      " |          If not specified the maximum value of the data (or gmap) will be used.\n",
      " |      \n",
      " |          .. versionadded:: 1.0.0\n",
      " |      \n",
      " |      gmap : array-like, optional\n",
      " |          Gradient map for determining the background colors. If not supplied\n",
      " |          will use the underlying data from rows, columns or frame. If given as an\n",
      " |          ndarray or list-like must be an identical shape to the underlying data\n",
      " |          considering ``axis`` and ``subset``. If given as DataFrame or Series must\n",
      " |          have same index and column labels considering ``axis`` and ``subset``.\n",
      " |          If supplied, ``vmin`` and ``vmax`` should be given relative to this\n",
      " |          gradient map.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.text_gradient: Color the text in a gradient style.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      When using ``low`` and ``high`` the range\n",
      " |      of the gradient, given by the data if ``gmap`` is not given or by ``gmap``,\n",
      " |      is extended at the low end effectively by\n",
      " |      `map.min - low * map.range` and at the high end by\n",
      " |      `map.max + high * map.range` before the colors are normalized and determined.\n",
      " |      \n",
      " |      If combining with ``vmin`` and ``vmax`` the `map.min`, `map.max` and\n",
      " |      `map.range` are replaced by values according to the values derived from\n",
      " |      ``vmin`` and ``vmax``.\n",
      " |      \n",
      " |      This method will preselect numeric columns and ignore non-numeric columns\n",
      " |      unless a ``gmap`` is supplied in which case no preselection occurs.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> df = pd.DataFrame(columns=[\"City\", \"Temp (c)\", \"Rain (mm)\", \"Wind (m/s)\"],\n",
      " |      ...                   data=[[\"Stockholm\", 21.6, 5.0, 3.2],\n",
      " |      ...                         [\"Oslo\", 22.4, 13.3, 3.1],\n",
      " |      ...                         [\"Copenhagen\", 24.5, 0.0, 6.7]])\n",
      " |      \n",
      " |      Shading the values column-wise, with ``axis=0``, preselecting numeric columns\n",
      " |      \n",
      " |      >>> df.style.background_gradient(axis=0)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/bg_ax0.png\n",
      " |      \n",
      " |      Shading all values collectively using ``axis=None``\n",
      " |      \n",
      " |      >>> df.style.background_gradient(axis=None)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/bg_axNone.png\n",
      " |      \n",
      " |      Compress the color map from the both ``low`` and ``high`` ends\n",
      " |      \n",
      " |      >>> df.style.background_gradient(axis=None, low=0.75, high=1.0)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/bg_axNone_lowhigh.png\n",
      " |      \n",
      " |      Manually setting ``vmin`` and ``vmax`` gradient thresholds\n",
      " |      \n",
      " |      >>> df.style.background_gradient(axis=None, vmin=6.7, vmax=21.6)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/bg_axNone_vminvmax.png\n",
      " |      \n",
      " |      Setting a ``gmap`` and applying to all columns with another ``cmap``\n",
      " |      \n",
      " |      >>> df.style.background_gradient(axis=0, gmap=df['Temp (c)'], cmap='YlOrRd')\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/bg_gmap.png\n",
      " |      \n",
      " |      Setting the gradient map for a dataframe (i.e. ``axis=None``), we need to\n",
      " |      explicitly state ``subset`` to match the ``gmap`` shape\n",
      " |      \n",
      " |      >>> gmap = np.array([[1,2,3], [2,3,4], [3,4,5]])\n",
      " |      >>> df.style.background_gradient(axis=None, gmap=gmap,\n",
      " |      ...     cmap='YlOrRd', subset=['Temp (c)', 'Rain (mm)', 'Wind (m/s)']\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/bg_axNone_gmap.png\n",
      " |  \n",
      " |  bar(self, subset: 'Subset | None' = None, axis: 'Axis | None' = 0, *, color: 'str | list | tuple | None' = None, cmap: 'Any | None' = None, width: 'float' = 100, height: 'float' = 100, align: 'str | float | int | Callable' = 'mid', vmin: 'float | None' = None, vmax: 'float | None' = None, props: 'str' = 'width: 10em;') -> 'Styler'\n",
      " |      Draw bar chart in the cell backgrounds.\n",
      " |      \n",
      " |      .. versionchanged:: 1.4.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``), or to the entire DataFrame at once\n",
      " |          with ``axis=None``.\n",
      " |      color : str or 2-tuple/list\n",
      " |          If a str is passed, the color is the same for both\n",
      " |          negative and positive numbers. If 2-tuple/list is used, the\n",
      " |          first element is the color_negative and the second is the\n",
      " |          color_positive (eg: ['#d65f5f', '#5fba7d']).\n",
      " |      cmap : str, matplotlib.cm.ColorMap\n",
      " |          A string name of a matplotlib Colormap, or a Colormap object. Cannot be\n",
      " |          used together with ``color``.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      width : float, default 100\n",
      " |          The percentage of the cell, measured from the left, in which to draw the\n",
      " |          bars, in [0, 100].\n",
      " |      height : float, default 100\n",
      " |          The percentage height of the bar in the cell, centrally aligned, in [0,100].\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      align : str, int, float, callable, default 'mid'\n",
      " |          How to align the bars within the cells relative to a width adjusted center.\n",
      " |          If string must be one of:\n",
      " |      \n",
      " |          - 'left' : bars are drawn rightwards from the minimum data value.\n",
      " |          - 'right' : bars are drawn leftwards from the maximum data value.\n",
      " |          - 'zero' : a value of zero is located at the center of the cell.\n",
      " |          - 'mid' : a value of (max-min)/2 is located at the center of the cell,\n",
      " |            or if all values are negative (positive) the zero is\n",
      " |            aligned at the right (left) of the cell.\n",
      " |          - 'mean' : the mean value of the data is located at the center of the cell.\n",
      " |      \n",
      " |          If a float or integer is given this will indicate the center of the cell.\n",
      " |      \n",
      " |          If a callable should take a 1d or 2d array and return a scalar.\n",
      " |      \n",
      " |          .. versionchanged:: 1.4.0\n",
      " |      \n",
      " |      vmin : float, optional\n",
      " |          Minimum bar value, defining the left hand limit\n",
      " |          of the bar drawing range, lower values are clipped to `vmin`.\n",
      " |          When None (default): the minimum value of the data will be used.\n",
      " |      vmax : float, optional\n",
      " |          Maximum bar value, defining the right hand limit\n",
      " |          of the bar drawing range, higher values are clipped to `vmax`.\n",
      " |          When None (default): the maximum value of the data will be used.\n",
      " |      props : str, optional\n",
      " |          The base CSS of the cell that is extended to add the bar chart. Defaults to\n",
      " |          `\"width: 10em;\"`.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This section of the user guide:\n",
      " |      `Table Visualization <../../user_guide/style.ipynb>`_ gives\n",
      " |      a number of examples for different settings and color coordination.\n",
      " |  \n",
      " |  clear(self) -> 'None'\n",
      " |      Reset the ``Styler``, removing any previously applied styles.\n",
      " |      \n",
      " |      Returns None.\n",
      " |  \n",
      " |  export(self) -> 'dict[str, Any]'\n",
      " |      Export the styles applied to the current Styler.\n",
      " |      \n",
      " |      Can be applied to a second Styler with ``Styler.use``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      styles : dict\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.use: Set the styles on the current Styler.\n",
      " |      Styler.copy: Create a copy of the current Styler.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method is designed to copy non-data dependent attributes of\n",
      " |      one Styler to another. It differs from ``Styler.copy`` where data and\n",
      " |      data dependent attributes are also copied.\n",
      " |      \n",
      " |      The following items are exported since they are not generally data dependent:\n",
      " |      \n",
      " |        - Styling functions added by the ``apply`` and ``applymap``\n",
      " |        - Whether axes and names are hidden from the display, if unambiguous.\n",
      " |        - Table attributes\n",
      " |        - Table styles\n",
      " |      \n",
      " |      The following attributes are considered data dependent and therefore not\n",
      " |      exported:\n",
      " |      \n",
      " |        - Caption\n",
      " |        - UUID\n",
      " |        - Tooltips\n",
      " |        - Any hidden rows or columns identified by Index labels\n",
      " |        - Any formatting applied using ``Styler.format``\n",
      " |        - Any CSS classes added using ``Styler.set_td_classes``\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      \n",
      " |      >>> styler = DataFrame([[1, 2], [3, 4]]).style\n",
      " |      >>> styler2 = DataFrame([[9, 9, 9]]).style\n",
      " |      >>> styler.hide(axis=0).highlight_max(axis=1)  # doctest: +SKIP\n",
      " |      >>> export = styler.export()\n",
      " |      >>> styler2.use(export)  # doctest: +SKIP\n",
      " |  \n",
      " |  hide(self, subset: 'Subset | None' = None, axis: 'Axis' = 0, level: 'Level | list[Level] | None' = None, names: 'bool' = False) -> 'Styler'\n",
      " |      Hide the entire index / column headers, or specific rows / columns from display.\n",
      " |      \n",
      " |      .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 1d input or single key along the axis within\n",
      " |          `DataFrame.loc[<subset>, :]` or `DataFrame.loc[:, <subset>]` depending\n",
      " |          upon ``axis``, to limit ``data`` to select hidden rows / columns.\n",
      " |      axis : {\"index\", 0, \"columns\", 1}\n",
      " |          Apply to the index or columns.\n",
      " |      level : int, str, list\n",
      " |          The level(s) to hide in a MultiIndex if hiding the entire index / column\n",
      " |          headers. Cannot be used simultaneously with ``subset``.\n",
      " |      names : bool\n",
      " |          Whether to hide the level name(s) of the index / columns headers in the case\n",
      " |          it (or at least one the levels) remains visible.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method has multiple functionality depending upon the combination\n",
      " |      of the ``subset``, ``level`` and ``names`` arguments (see examples). The\n",
      " |      ``axis`` argument is used only to control whether the method is applied to row\n",
      " |      or column headers:\n",
      " |      \n",
      " |      .. list-table:: Argument combinations\n",
      " |         :widths: 10 20 10 60\n",
      " |         :header-rows: 1\n",
      " |      \n",
      " |         * - ``subset``\n",
      " |           - ``level``\n",
      " |           - ``names``\n",
      " |           - Effect\n",
      " |         * - None\n",
      " |           - None\n",
      " |           - False\n",
      " |           - The axis-Index is hidden entirely.\n",
      " |         * - None\n",
      " |           - None\n",
      " |           - True\n",
      " |           - Only the axis-Index names are hidden.\n",
      " |         * - None\n",
      " |           - Int, Str, List\n",
      " |           - False\n",
      " |           - Specified axis-MultiIndex levels are hidden entirely.\n",
      " |         * - None\n",
      " |           - Int, Str, List\n",
      " |           - True\n",
      " |           - Specified axis-MultiIndex levels are hidden entirely and the names of\n",
      " |             remaining axis-MultiIndex levels.\n",
      " |         * - Subset\n",
      " |           - None\n",
      " |           - False\n",
      " |           - The specified data rows/columns are hidden, but the axis-Index itself,\n",
      " |             and names, remain unchanged.\n",
      " |         * - Subset\n",
      " |           - None\n",
      " |           - True\n",
      " |           - The specified data rows/columns and axis-Index names are hidden, but\n",
      " |             the axis-Index itself remains unchanged.\n",
      " |         * - Subset\n",
      " |           - Int, Str, List\n",
      " |           - Boolean\n",
      " |           - ValueError: cannot supply ``subset`` and ``level`` simultaneously.\n",
      " |      \n",
      " |      Note this method only hides the identifed elements so can be chained to hide\n",
      " |      multiple elements in sequence.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Simple application hiding specific rows:\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1,2], [3,4], [5,6]], index=[\"a\", \"b\", \"c\"])\n",
      " |      >>> df.style.hide([\"a\", \"b\"])  # doctest: +SKIP\n",
      " |           0    1\n",
      " |      c    5    6\n",
      " |      \n",
      " |      Hide the index and retain the data values:\n",
      " |      \n",
      " |      >>> midx = pd.MultiIndex.from_product([[\"x\", \"y\"], [\"a\", \"b\", \"c\"]])\n",
      " |      >>> df = pd.DataFrame(np.random.randn(6,6), index=midx, columns=midx)\n",
      " |      >>> df.style.format(\"{:.1f}\").hide()  # doctest: +SKIP\n",
      " |                       x                    y\n",
      " |         a      b      c      a      b      c\n",
      " |       0.1    0.0    0.4    1.3    0.6   -1.4\n",
      " |       0.7    1.0    1.3    1.5   -0.0   -0.2\n",
      " |       1.4   -0.8    1.6   -0.2   -0.4   -0.3\n",
      " |       0.4    1.0   -0.2   -0.8   -1.2    1.1\n",
      " |      -0.6    1.2    1.8    1.9    0.3    0.3\n",
      " |       0.8    0.5   -0.3    1.2    2.2   -0.8\n",
      " |      \n",
      " |      Hide specific rows in a MultiIndex but retain the index:\n",
      " |      \n",
      " |      >>> df.style.format(\"{:.1f}\").hide(subset=(slice(None), [\"a\", \"c\"]))\n",
      " |      ...   # doctest: +SKIP\n",
      " |                               x                    y\n",
      " |                 a      b      c      a      b      c\n",
      " |      x   b    0.7    1.0    1.3    1.5   -0.0   -0.2\n",
      " |      y   b   -0.6    1.2    1.8    1.9    0.3    0.3\n",
      " |      \n",
      " |      Hide specific rows and the index through chaining:\n",
      " |      \n",
      " |      >>> df.style.format(\"{:.1f}\").hide(subset=(slice(None), [\"a\", \"c\"])).hide()\n",
      " |      ...   # doctest: +SKIP\n",
      " |                       x                    y\n",
      " |         a      b      c      a      b      c\n",
      " |       0.7    1.0    1.3    1.5   -0.0   -0.2\n",
      " |      -0.6    1.2    1.8    1.9    0.3    0.3\n",
      " |      \n",
      " |      Hide a specific level:\n",
      " |      \n",
      " |      >>> df.style.format(\"{:,.1f}\").hide(level=1)  # doctest: +SKIP\n",
      " |                           x                    y\n",
      " |             a      b      c      a      b      c\n",
      " |      x    0.1    0.0    0.4    1.3    0.6   -1.4\n",
      " |           0.7    1.0    1.3    1.5   -0.0   -0.2\n",
      " |           1.4   -0.8    1.6   -0.2   -0.4   -0.3\n",
      " |      y    0.4    1.0   -0.2   -0.8   -1.2    1.1\n",
      " |          -0.6    1.2    1.8    1.9    0.3    0.3\n",
      " |           0.8    0.5   -0.3    1.2    2.2   -0.8\n",
      " |      \n",
      " |      Hiding just the index level names:\n",
      " |      \n",
      " |      >>> df.index.names = [\"lev0\", \"lev1\"]\n",
      " |      >>> df.style.format(\"{:,.1f}\").hide(names=True)  # doctest: +SKIP\n",
      " |                               x                    y\n",
      " |                 a      b      c      a      b      c\n",
      " |      x   a    0.1    0.0    0.4    1.3    0.6   -1.4\n",
      " |          b    0.7    1.0    1.3    1.5   -0.0   -0.2\n",
      " |          c    1.4   -0.8    1.6   -0.2   -0.4   -0.3\n",
      " |      y   a    0.4    1.0   -0.2   -0.8   -1.2    1.1\n",
      " |          b   -0.6    1.2    1.8    1.9    0.3    0.3\n",
      " |          c    0.8    0.5   -0.3    1.2    2.2   -0.8\n",
      " |      \n",
      " |      Examples all produce equivalently transposed effects with ``axis=\"columns\"``.\n",
      " |  \n",
      " |  hide_columns(self, subset: 'Subset | None' = None, level: 'Level | list[Level] | None' = None, names: 'bool' = False) -> 'Styler'\n",
      " |      Hide the column headers or specific keys in the columns from rendering.\n",
      " |      \n",
      " |      This method has dual functionality:\n",
      " |      \n",
      " |        - if ``subset`` is ``None`` then the entire column headers row, or\n",
      " |          specific levels, will be hidden whilst the data-values remain visible.\n",
      " |        - if a ``subset`` is given then those specific columns, including the\n",
      " |          data-values will be hidden, whilst the column headers row remains visible.\n",
      " |      \n",
      " |      .. versionchanged:: 1.3.0\n",
      " |      \n",
      " |      ..deprecated:: 1.4.0\n",
      " |        This method should be replaced by ``hide(axis=\"columns\", **kwargs)``\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 1d input or single key along the columns axis within\n",
      " |          `DataFrame.loc[:, <subset>]`, to limit ``data`` to *before* applying\n",
      " |          the function.\n",
      " |      level : int, str, list\n",
      " |          The level(s) to hide in a MultiIndex if hiding the entire column headers\n",
      " |          row. Cannot be used simultaneously with ``subset``.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      names : bool\n",
      " |          Whether to hide the column index name(s), in the case all column headers,\n",
      " |          or some levels, are visible.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.hide: Hide the entire index / columns, or specific rows / columns.\n",
      " |  \n",
      " |  hide_index(self, subset: 'Subset | None' = None, level: 'Level | list[Level] | None' = None, names: 'bool' = False) -> 'Styler'\n",
      " |      Hide the entire index, or specific keys in the index from rendering.\n",
      " |      \n",
      " |      This method has dual functionality:\n",
      " |      \n",
      " |        - if ``subset`` is ``None`` then the entire index, or specified levels, will\n",
      " |          be hidden whilst displaying all data-rows.\n",
      " |        - if a ``subset`` is given then those specific rows will be hidden whilst the\n",
      " |          index itself remains visible.\n",
      " |      \n",
      " |      .. versionchanged:: 1.3.0\n",
      " |      \n",
      " |      .. deprecated:: 1.4.0\n",
      " |         This method should be replaced by ``hide(axis=\"index\", **kwargs)``\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 1d input or single key along the index axis within\n",
      " |          `DataFrame.loc[<subset>, :]`, to limit ``data`` to *before* applying\n",
      " |          the function.\n",
      " |      level : int, str, list\n",
      " |          The level(s) to hide in a MultiIndex if hiding the entire index. Cannot be\n",
      " |          used simultaneously with ``subset``.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      names : bool\n",
      " |          Whether to hide the index name(s), in the case the index or part of it\n",
      " |          remains visible.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.hide: Hide the entire index / columns, or specific rows / columns.\n",
      " |  \n",
      " |  highlight_between(self, subset: 'Subset | None' = None, color: 'str' = 'yellow', axis: 'Axis | None' = 0, left: 'Scalar | Sequence | None' = None, right: 'Scalar | Sequence | None' = None, inclusive: 'str' = 'both', props: 'str | None' = None) -> 'Styler'\n",
      " |      Highlight a defined range with a style.\n",
      " |      \n",
      " |      .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      color : str, default 'yellow'\n",
      " |          Background color to use for highlighting.\n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          If ``left`` or ``right`` given as sequence, axis along which to apply those\n",
      " |          boundaries. See examples.\n",
      " |      left : scalar or datetime-like, or sequence or array-like, default None\n",
      " |          Left bound for defining the range.\n",
      " |      right : scalar or datetime-like, or sequence or array-like, default None\n",
      " |          Right bound for defining the range.\n",
      " |      inclusive : {'both', 'neither', 'left', 'right'}\n",
      " |          Identify whether bounds are closed or open.\n",
      " |      \n",
      " |      props : str, default None\n",
      " |          CSS properties to use for highlighting. If ``props`` is given, ``color``\n",
      " |          is not used.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.highlight_null: Highlight missing values with a style.\n",
      " |      Styler.highlight_max: Highlight the maximum with a style.\n",
      " |      Styler.highlight_min: Highlight the minimum with a style.\n",
      " |      Styler.highlight_quantile: Highlight values defined by a quantile with a style.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      If ``left`` is ``None`` only the right bound is applied.\n",
      " |      If ``right`` is ``None`` only the left bound is applied. If both are ``None``\n",
      " |      all values are highlighted.\n",
      " |      \n",
      " |      ``axis`` is only needed if ``left`` or ``right`` are provided as a sequence or\n",
      " |      an array-like object for aligning the shapes. If ``left`` and ``right`` are\n",
      " |      both scalars then all ``axis`` inputs will give the same result.\n",
      " |      \n",
      " |      This function only works with compatible ``dtypes``. For example a datetime-like\n",
      " |      region can only use equivalent datetime-like ``left`` and ``right`` arguments.\n",
      " |      Use ``subset`` to control regions which have multiple ``dtypes``.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Basic usage\n",
      " |      \n",
      " |      >>> df = pd.DataFrame({\n",
      " |      ...     'One': [1.2, 1.6, 1.5],\n",
      " |      ...     'Two': [2.9, 2.1, 2.5],\n",
      " |      ...     'Three': [3.1, 3.2, 3.8],\n",
      " |      ... })\n",
      " |      >>> df.style.highlight_between(left=2.1, right=2.9)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hbetw_basic.png\n",
      " |      \n",
      " |      Using a range input sequnce along an ``axis``, in this case setting a ``left``\n",
      " |      and ``right`` for each column individually\n",
      " |      \n",
      " |      >>> df.style.highlight_between(left=[1.4, 2.4, 3.4], right=[1.6, 2.6, 3.6],\n",
      " |      ...     axis=1, color=\"#fffd75\")  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hbetw_seq.png\n",
      " |      \n",
      " |      Using ``axis=None`` and providing the ``left`` argument as an array that\n",
      " |      matches the input DataFrame, with a constant ``right``\n",
      " |      \n",
      " |      >>> df.style.highlight_between(left=[[2,2,3],[2,2,3],[3,3,3]], right=3.5,\n",
      " |      ...     axis=None, color=\"#fffd75\")  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hbetw_axNone.png\n",
      " |      \n",
      " |      Using ``props`` instead of default background coloring\n",
      " |      \n",
      " |      >>> df.style.highlight_between(left=1.5, right=3.5,\n",
      " |      ...     props='font-weight:bold;color:#e83e8c')  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hbetw_props.png\n",
      " |  \n",
      " |  highlight_max(self, subset: 'Subset | None' = None, color: 'str' = 'yellow', axis: 'Axis | None' = 0, props: 'str | None' = None) -> 'Styler'\n",
      " |      Highlight the maximum with a style.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      color : str, default 'yellow'\n",
      " |          Background color to use for highlighting.\n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``), or to the entire DataFrame at once\n",
      " |          with ``axis=None``.\n",
      " |      \n",
      " |      props : str, default None\n",
      " |          CSS properties to use for highlighting. If ``props`` is given, ``color``\n",
      " |          is not used.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.highlight_null: Highlight missing values with a style.\n",
      " |      Styler.highlight_min: Highlight the minimum with a style.\n",
      " |      Styler.highlight_between: Highlight a defined range with a style.\n",
      " |      Styler.highlight_quantile: Highlight values defined by a quantile with a style.\n",
      " |  \n",
      " |  highlight_min(self, subset: 'Subset | None' = None, color: 'str' = 'yellow', axis: 'Axis | None' = 0, props: 'str | None' = None) -> 'Styler'\n",
      " |      Highlight the minimum with a style.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      color : str, default 'yellow'\n",
      " |          Background color to use for highlighting.\n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``), or to the entire DataFrame at once\n",
      " |          with ``axis=None``.\n",
      " |      \n",
      " |      props : str, default None\n",
      " |          CSS properties to use for highlighting. If ``props`` is given, ``color``\n",
      " |          is not used.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.highlight_null: Highlight missing values with a style.\n",
      " |      Styler.highlight_max: Highlight the maximum with a style.\n",
      " |      Styler.highlight_between: Highlight a defined range with a style.\n",
      " |      Styler.highlight_quantile: Highlight values defined by a quantile with a style.\n",
      " |  \n",
      " |  highlight_null(self, null_color: 'str' = 'red', subset: 'Subset | None' = None, props: 'str | None' = None) -> 'Styler'\n",
      " |      Highlight missing values with a style.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      null_color : str, default 'red'\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |          .. versionadded:: 1.1.0\n",
      " |      \n",
      " |      props : str, default None\n",
      " |          CSS properties to use for highlighting. If ``props`` is given, ``color``\n",
      " |          is not used.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.highlight_max: Highlight the maximum with a style.\n",
      " |      Styler.highlight_min: Highlight the minimum with a style.\n",
      " |      Styler.highlight_between: Highlight a defined range with a style.\n",
      " |      Styler.highlight_quantile: Highlight values defined by a quantile with a style.\n",
      " |  \n",
      " |  highlight_quantile(self, subset: 'Subset | None' = None, color: 'str' = 'yellow', axis: 'Axis | None' = 0, q_left: 'float' = 0.0, q_right: 'float' = 1.0, interpolation: 'str' = 'linear', inclusive: 'str' = 'both', props: 'str | None' = None) -> 'Styler'\n",
      " |      Highlight values defined by a quantile with a style.\n",
      " |      \n",
      " |      .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      color : str, default 'yellow'\n",
      " |          Background color to use for highlighting.\n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Axis along which to determine and highlight quantiles. If ``None`` quantiles\n",
      " |          are measured over the entire DataFrame. See examples.\n",
      " |      q_left : float, default 0\n",
      " |          Left bound, in [0, q_right), for the target quantile range.\n",
      " |      q_right : float, default 1\n",
      " |          Right bound, in (q_left, 1], for the target quantile range.\n",
      " |      interpolation : {‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}\n",
      " |          Argument passed to ``Series.quantile`` or ``DataFrame.quantile`` for\n",
      " |          quantile estimation.\n",
      " |      inclusive : {'both', 'neither', 'left', 'right'}\n",
      " |          Identify whether quantile bounds are closed or open.\n",
      " |      \n",
      " |      props : str, default None\n",
      " |          CSS properties to use for highlighting. If ``props`` is given, ``color``\n",
      " |          is not used.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.highlight_null: Highlight missing values with a style.\n",
      " |      Styler.highlight_max: Highlight the maximum with a style.\n",
      " |      Styler.highlight_min: Highlight the minimum with a style.\n",
      " |      Styler.highlight_between: Highlight a defined range with a style.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This function does not work with ``str`` dtypes.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Using ``axis=None`` and apply a quantile to all collective data\n",
      " |      \n",
      " |      >>> df = pd.DataFrame(np.arange(10).reshape(2,5) + 1)\n",
      " |      >>> df.style.highlight_quantile(axis=None, q_left=0.8, color=\"#fffd75\")\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hq_axNone.png\n",
      " |      \n",
      " |      Or highlight quantiles row-wise or column-wise, in this case by row-wise\n",
      " |      \n",
      " |      >>> df.style.highlight_quantile(axis=1, q_left=0.8, color=\"#fffd75\")\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hq_ax1.png\n",
      " |      \n",
      " |      Use ``props`` instead of default background coloring\n",
      " |      \n",
      " |      >>> df.style.highlight_quantile(axis=None, q_left=0.2, q_right=0.8,\n",
      " |      ...     props='font-weight:bold;color:#e83e8c')  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/hq_props.png\n",
      " |  \n",
      " |  pipe(self, func: 'Callable', *args, **kwargs)\n",
      " |      Apply ``func(self, *args, **kwargs)``, and return the result.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      func : function\n",
      " |          Function to apply to the Styler.  Alternatively, a\n",
      " |          ``(callable, keyword)`` tuple where ``keyword`` is a string\n",
      " |          indicating the keyword of ``callable`` that expects the Styler.\n",
      " |      *args : optional\n",
      " |          Arguments passed to `func`.\n",
      " |      **kwargs : optional\n",
      " |          A dictionary of keyword arguments passed into ``func``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      object :\n",
      " |          The value returned by ``func``.\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      DataFrame.pipe : Analogous method for DataFrame.\n",
      " |      Styler.apply : Apply a CSS-styling function column-wise, row-wise, or\n",
      " |          table-wise.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      Like :meth:`DataFrame.pipe`, this method can simplify the\n",
      " |      application of several user-defined functions to a styler.  Instead\n",
      " |      of writing:\n",
      " |      \n",
      " |      .. code-block:: python\n",
      " |      \n",
      " |          f(g(df.style.set_precision(3), arg1=a), arg2=b, arg3=c)\n",
      " |      \n",
      " |      users can write:\n",
      " |      \n",
      " |      .. code-block:: python\n",
      " |      \n",
      " |          (df.style.set_precision(3)\n",
      " |             .pipe(g, arg1=a)\n",
      " |             .pipe(f, arg2=b, arg3=c))\n",
      " |      \n",
      " |      In particular, this allows users to define functions that take a\n",
      " |      styler object, along with other parameters, and return the styler after\n",
      " |      making styling changes (such as calling :meth:`Styler.apply` or\n",
      " |      :meth:`Styler.set_properties`).  Using ``.pipe``, these user-defined\n",
      " |      style \"transformations\" can be interleaved with calls to the built-in\n",
      " |      Styler interface.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> def format_conversion(styler):\n",
      " |      ...     return (styler.set_properties(**{'text-align': 'right'})\n",
      " |      ...                   .format({'conversion': '{:.1%}'}))\n",
      " |      \n",
      " |      The user-defined ``format_conversion`` function above can be called\n",
      " |      within a sequence of other style modifications:\n",
      " |      \n",
      " |      >>> df = pd.DataFrame({'trial': list(range(5)),\n",
      " |      ...                    'conversion': [0.75, 0.85, np.nan, 0.7, 0.72]})\n",
      " |      >>> (df.style\n",
      " |      ...    .highlight_min(subset=['conversion'], color='yellow')\n",
      " |      ...    .pipe(format_conversion)\n",
      " |      ...    .set_caption(\"Results with minimum conversion highlighted.\"))\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/df_pipe.png\n",
      " |  \n",
      " |  render(self, sparse_index: 'bool | None' = None, sparse_columns: 'bool | None' = None, **kwargs) -> 'str'\n",
      " |      Render the ``Styler`` including all applied styles to HTML.\n",
      " |      \n",
      " |      .. deprecated:: 1.4.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      sparse_index : bool, optional\n",
      " |          Whether to sparsify the display of a hierarchical index. Setting to False\n",
      " |          will display each explicit level element in a hierarchical key for each row.\n",
      " |          Defaults to ``pandas.options.styler.sparse.index`` value.\n",
      " |      sparse_columns : bool, optional\n",
      " |          Whether to sparsify the display of a hierarchical index. Setting to False\n",
      " |          will display each explicit level element in a hierarchical key for each row.\n",
      " |          Defaults to ``pandas.options.styler.sparse.columns`` value.\n",
      " |      **kwargs\n",
      " |          Any additional keyword arguments are passed\n",
      " |          through to ``self.template.render``.\n",
      " |          This is useful when you need to provide\n",
      " |          additional variables for a custom template.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      rendered : str\n",
      " |          The rendered HTML.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method is deprecated in favour of ``Styler.to_html``.\n",
      " |      \n",
      " |      Styler objects have defined the ``_repr_html_`` method\n",
      " |      which automatically calls ``self.to_html()`` when it's the\n",
      " |      last item in a Notebook cell.\n",
      " |      \n",
      " |      When calling ``Styler.render()`` directly, wrap the result in\n",
      " |      ``IPython.display.HTML`` to view the rendered HTML in the notebook.\n",
      " |      \n",
      " |      Pandas uses the following keys in render. Arguments passed\n",
      " |      in ``**kwargs`` take precedence, so think carefully if you want\n",
      " |      to override them:\n",
      " |      \n",
      " |      * head\n",
      " |      * cellstyle\n",
      " |      * body\n",
      " |      * uuid\n",
      " |      * table_styles\n",
      " |      * caption\n",
      " |      * table_attributes\n",
      " |  \n",
      " |  set_caption(self, caption: 'str | tuple') -> 'Styler'\n",
      " |      Set the text added to a ``<caption>`` HTML element.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      caption : str, tuple\n",
      " |          For HTML output either the string input is used or the first element of the\n",
      " |          tuple. For LaTeX the string input provides a caption and the additional\n",
      " |          tuple input allows for full captions and short captions, in that order.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |  \n",
      " |  set_na_rep(self, na_rep: 'str') -> 'StylerRenderer'\n",
      " |      Set the missing data representation on a ``Styler``.\n",
      " |      \n",
      " |      .. versionadded:: 1.0.0\n",
      " |      \n",
      " |      .. deprecated:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      na_rep : str\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method is deprecated. See `Styler.format()`\n",
      " |  \n",
      " |  set_precision(self, precision: 'int') -> 'StylerRenderer'\n",
      " |      Set the precision used to display values.\n",
      " |      \n",
      " |      .. deprecated:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      precision : int\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method is deprecated see `Styler.format`.\n",
      " |  \n",
      " |  set_properties(self, subset: 'Subset | None' = None, **kwargs) -> 'Styler'\n",
      " |      Set defined CSS-properties to each ``<td>`` HTML element within the given\n",
      " |      subset.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      **kwargs : dict\n",
      " |          A dictionary of property, value pairs to be set for each cell.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This is a convenience methods which wraps the :meth:`Styler.applymap` calling a\n",
      " |      function returning the CSS-properties independently of the data.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> df = pd.DataFrame(np.random.randn(10, 4))\n",
      " |      >>> df.style.set_properties(color=\"white\", align=\"right\")  # doctest: +SKIP\n",
      " |      >>> df.style.set_properties(**{'background-color': 'yellow'})  # doctest: +SKIP\n",
      " |      \n",
      " |      See `Table Visualization <../../user_guide/style.ipynb>`_ user guide for\n",
      " |      more details.\n",
      " |  \n",
      " |  set_sticky(self, axis: 'Axis' = 0, pixel_size: 'int | None' = None, levels: 'Level | list[Level] | None' = None) -> 'Styler'\n",
      " |      Add CSS to permanently display the index or column headers in a scrolling frame.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      axis : {0 or 'index', 1 or 'columns'}, default 0\n",
      " |          Whether to make the index or column headers sticky.\n",
      " |      pixel_size : int, optional\n",
      " |          Required to configure the width of index cells or the height of column\n",
      " |          header cells when sticking a MultiIndex (or with a named Index).\n",
      " |          Defaults to 75 and 25 respectively.\n",
      " |      levels : int, str, list, optional\n",
      " |          If ``axis`` is a MultiIndex the specific levels to stick. If ``None`` will\n",
      " |          stick all levels.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method uses the CSS 'position: sticky;' property to display. It is\n",
      " |      designed to work with visible axes, therefore both:\n",
      " |      \n",
      " |        - `styler.set_sticky(axis=\"index\").hide(axis=\"index\")`\n",
      " |        - `styler.set_sticky(axis=\"columns\").hide(axis=\"columns\")`\n",
      " |      \n",
      " |      may produce strange behaviour due to CSS controls with missing elements.\n",
      " |  \n",
      " |  set_table_attributes(self, attributes: 'str') -> 'Styler'\n",
      " |      Set the table attributes added to the ``<table>`` HTML element.\n",
      " |      \n",
      " |      These are items in addition to automatic (by default) ``id`` attribute.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      attributes : str\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.set_table_styles: Set the table styles included within the ``<style>``\n",
      " |          HTML element.\n",
      " |      Styler.set_td_classes: Set the DataFrame of strings added to the ``class``\n",
      " |          attribute of ``<td>`` HTML elements.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> df = pd.DataFrame(np.random.randn(10, 4))\n",
      " |      >>> df.style.set_table_attributes('class=\"pure-table\"')  # doctest: +SKIP\n",
      " |      # ... <table class=\"pure-table\"> ...\n",
      " |  \n",
      " |  set_table_styles(self, table_styles: 'dict[Any, CSSStyles] | CSSStyles | None' = None, axis: 'int' = 0, overwrite: 'bool' = True, css_class_names: 'dict[str, str] | None' = None) -> 'Styler'\n",
      " |      Set the table styles included within the ``<style>`` HTML element.\n",
      " |      \n",
      " |      This function can be used to style the entire table, columns, rows or\n",
      " |      specific HTML selectors.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      table_styles : list or dict\n",
      " |          If supplying a list, each individual table_style should be a\n",
      " |          dictionary with ``selector`` and ``props`` keys. ``selector``\n",
      " |          should be a CSS selector that the style will be applied to\n",
      " |          (automatically prefixed by the table's UUID) and ``props``\n",
      " |          should be a list of tuples with ``(attribute, value)``.\n",
      " |          If supplying a dict, the dict keys should correspond to\n",
      " |          column names or index values, depending upon the specified\n",
      " |          `axis` argument. These will be mapped to row or col CSS\n",
      " |          selectors. MultiIndex values as dict keys should be\n",
      " |          in their respective tuple form. The dict values should be\n",
      " |          a list as specified in the form with CSS selectors and\n",
      " |          props that will be applied to the specified row or column.\n",
      " |      \n",
      " |          .. versionchanged:: 1.2.0\n",
      " |      \n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``). Only used if `table_styles` is\n",
      " |          dict.\n",
      " |      \n",
      " |          .. versionadded:: 1.2.0\n",
      " |      \n",
      " |      overwrite : bool, default True\n",
      " |          Styles are replaced if `True`, or extended if `False`. CSS\n",
      " |          rules are preserved so most recent styles set will dominate\n",
      " |          if selectors intersect.\n",
      " |      \n",
      " |          .. versionadded:: 1.2.0\n",
      " |      \n",
      " |      css_class_names : dict, optional\n",
      " |          A dict of strings used to replace the default CSS classes described below.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.set_td_classes: Set the DataFrame of strings added to the ``class``\n",
      " |          attribute of ``<td>`` HTML elements.\n",
      " |      Styler.set_table_attributes: Set the table attributes added to the ``<table>``\n",
      " |          HTML element.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      The default CSS classes dict, whose values can be replaced is as follows:\n",
      " |      \n",
      " |      .. code-block:: python\n",
      " |      \n",
      " |          css_class_names = {\"row_heading\": \"row_heading\",\n",
      " |                             \"col_heading\": \"col_heading\",\n",
      " |                             \"index_name\": \"index_name\",\n",
      " |                             \"col\": \"col\",\n",
      " |                             \"col_trim\": \"col_trim\",\n",
      " |                             \"row_trim\": \"row_trim\",\n",
      " |                             \"level\": \"level\",\n",
      " |                             \"data\": \"data\",\n",
      " |                             \"blank\": \"blank}\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> df = pd.DataFrame(np.random.randn(10, 4),\n",
      " |      ...                   columns=['A', 'B', 'C', 'D'])\n",
      " |      >>> df.style.set_table_styles(\n",
      " |      ...     [{'selector': 'tr:hover',\n",
      " |      ...       'props': [('background-color', 'yellow')]}]\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \n",
      " |      Or with CSS strings\n",
      " |      \n",
      " |      >>> df.style.set_table_styles(\n",
      " |      ...     [{'selector': 'tr:hover',\n",
      " |      ...       'props': 'background-color: yellow; font-size: 1em;'}]\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \n",
      " |      Adding column styling by name\n",
      " |      \n",
      " |      >>> df.style.set_table_styles({\n",
      " |      ...     'A': [{'selector': '',\n",
      " |      ...            'props': [('color', 'red')]}],\n",
      " |      ...     'B': [{'selector': 'td',\n",
      " |      ...            'props': 'color: blue;'}]\n",
      " |      ... }, overwrite=False)  # doctest: +SKIP\n",
      " |      \n",
      " |      Adding row styling\n",
      " |      \n",
      " |      >>> df.style.set_table_styles({\n",
      " |      ...     0: [{'selector': 'td:hover',\n",
      " |      ...          'props': [('font-size', '25px')]}]\n",
      " |      ... }, axis=1, overwrite=False)  # doctest: +SKIP\n",
      " |      \n",
      " |      See `Table Visualization <../../user_guide/style.ipynb>`_ user guide for\n",
      " |      more details.\n",
      " |  \n",
      " |  set_td_classes(self, classes: 'DataFrame') -> 'Styler'\n",
      " |      Set the DataFrame of strings added to the ``class`` attribute of ``<td>``\n",
      " |      HTML elements.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      classes : DataFrame\n",
      " |          DataFrame containing strings that will be translated to CSS classes,\n",
      " |          mapped by identical column and index key values that must exist on the\n",
      " |          underlying Styler data. None, NaN values, and empty strings will\n",
      " |          be ignored and not affect the rendered HTML.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.set_table_styles: Set the table styles included within the ``<style>``\n",
      " |          HTML element.\n",
      " |      Styler.set_table_attributes: Set the table attributes added to the ``<table>``\n",
      " |          HTML element.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      Can be used in combination with ``Styler.set_table_styles`` to define an\n",
      " |      internal CSS solution without reference to external CSS files.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> df = pd.DataFrame(data=[[1, 2, 3], [4, 5, 6]], columns=[\"A\", \"B\", \"C\"])\n",
      " |      >>> classes = pd.DataFrame([\n",
      " |      ...     [\"min-val red\", \"\", \"blue\"],\n",
      " |      ...     [\"red\", None, \"blue max-val\"]\n",
      " |      ... ], index=df.index, columns=df.columns)\n",
      " |      >>> df.style.set_td_classes(classes)  # doctest: +SKIP\n",
      " |      \n",
      " |      Using `MultiIndex` columns and a `classes` `DataFrame` as a subset of the\n",
      " |      underlying,\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1,2],[3,4]], index=[\"a\", \"b\"],\n",
      " |      ...     columns=[[\"level0\", \"level0\"], [\"level1a\", \"level1b\"]])\n",
      " |      >>> classes = pd.DataFrame([\"min-val\"], index=[\"a\"],\n",
      " |      ...     columns=[[\"level0\"],[\"level1a\"]])\n",
      " |      >>> df.style.set_td_classes(classes)  # doctest: +SKIP\n",
      " |      \n",
      " |      Form of the output with new additional css classes,\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1]])\n",
      " |      >>> css = pd.DataFrame([[\"other-class\"]])\n",
      " |      >>> s = Styler(df, uuid=\"_\", cell_ids=False).set_td_classes(css)\n",
      " |      >>> s.hide(axis=0).to_html()  # doctest: +SKIP\n",
      " |      '<style type=\"text/css\"></style>'\n",
      " |      '<table id=\"T__\">'\n",
      " |      '  <thead>'\n",
      " |      '    <tr><th class=\"col_heading level0 col0\" >0</th></tr>'\n",
      " |      '  </thead>'\n",
      " |      '  <tbody>'\n",
      " |      '    <tr><td class=\"data row0 col0 other-class\" >1</td></tr>'\n",
      " |      '  </tbody>'\n",
      " |      '</table>'\n",
      " |  \n",
      " |  set_tooltips(self, ttips: 'DataFrame', props: 'CSSProperties | None' = None, css_class: 'str | None' = None) -> 'Styler'\n",
      " |      Set the DataFrame of strings on ``Styler`` generating ``:hover`` tooltips.\n",
      " |      \n",
      " |      These string based tooltips are only applicable to ``<td>`` HTML elements,\n",
      " |      and cannot be used for column or index headers.\n",
      " |      \n",
      " |      .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      ttips : DataFrame\n",
      " |          DataFrame containing strings that will be translated to tooltips, mapped\n",
      " |          by identical column and index values that must exist on the underlying\n",
      " |          Styler data. None, NaN values, and empty strings will be ignored and\n",
      " |          not affect the rendered HTML.\n",
      " |      props : list-like or str, optional\n",
      " |          List of (attr, value) tuples or a valid CSS string. If ``None`` adopts\n",
      " |          the internal default values described in notes.\n",
      " |      css_class : str, optional\n",
      " |          Name of the tooltip class used in CSS, should conform to HTML standards.\n",
      " |          Only useful if integrating tooltips with external CSS. If ``None`` uses the\n",
      " |          internal default value 'pd-t'.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      Tooltips are created by adding `<span class=\"pd-t\"></span>` to each data cell\n",
      " |      and then manipulating the table level CSS to attach pseudo hover and pseudo\n",
      " |      after selectors to produce the required the results.\n",
      " |      \n",
      " |      The default properties for the tooltip CSS class are:\n",
      " |      \n",
      " |      - visibility: hidden\n",
      " |      - position: absolute\n",
      " |      - z-index: 1\n",
      " |      - background-color: black\n",
      " |      - color: white\n",
      " |      - transform: translate(-20px, -20px)\n",
      " |      \n",
      " |      The property 'visibility: hidden;' is a key prerequisite to the hover\n",
      " |      functionality, and should always be included in any manual properties\n",
      " |      specification, using the ``props`` argument.\n",
      " |      \n",
      " |      Tooltips are not designed to be efficient, and can add large amounts of\n",
      " |      additional HTML for larger tables, since they also require that ``cell_ids``\n",
      " |      is forced to `True`.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Basic application\n",
      " |      \n",
      " |      >>> df = pd.DataFrame(data=[[0, 1], [2, 3]])\n",
      " |      >>> ttips = pd.DataFrame(\n",
      " |      ...    data=[[\"Min\", \"\"], [np.nan, \"Max\"]], columns=df.columns, index=df.index\n",
      " |      ... )\n",
      " |      >>> s = df.style.set_tooltips(ttips).to_html()\n",
      " |      \n",
      " |      Optionally controlling the tooltip visual display\n",
      " |      \n",
      " |      >>> df.style.set_tooltips(ttips, css_class='tt-add', props=[\n",
      " |      ...     ('visibility', 'hidden'),\n",
      " |      ...     ('position', 'absolute'),\n",
      " |      ...     ('z-index', 1)])  # doctest: +SKIP\n",
      " |      >>> df.style.set_tooltips(ttips, css_class='tt-add',\n",
      " |      ...     props='visibility:hidden; position:absolute; z-index:1;')\n",
      " |      ... # doctest: +SKIP\n",
      " |  \n",
      " |  set_uuid(self, uuid: 'str') -> 'Styler'\n",
      " |      Set the uuid applied to ``id`` attributes of HTML elements.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      uuid : str\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      Almost all HTML elements within the table, and including the ``<table>`` element\n",
      " |      are assigned ``id`` attributes. The format is ``T_uuid_<extra>`` where\n",
      " |      ``<extra>`` is typically a more specific identifier, such as ``row1_col2``.\n",
      " |  \n",
      " |  text_gradient(self, cmap='PuBu', low: 'float' = 0, high: 'float' = 0, axis: 'Axis | None' = 0, subset: 'Subset | None' = None, vmin: 'float | None' = None, vmax: 'float | None' = None, gmap: 'Sequence | None' = None) -> 'Styler'\n",
      " |      Color the text in a gradient style.\n",
      " |      \n",
      " |      The text color is determined according\n",
      " |      to the data in each column, row or frame, or by a given\n",
      " |      gradient map. Requires matplotlib.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      cmap : str or colormap\n",
      " |          Matplotlib colormap.\n",
      " |      low : float\n",
      " |          Compress the color range at the low end. This is a multiple of the data\n",
      " |          range to extend below the minimum; good values usually in [0, 1],\n",
      " |          defaults to 0.\n",
      " |      high : float\n",
      " |          Compress the color range at the high end. This is a multiple of the data\n",
      " |          range to extend above the maximum; good values usually in [0, 1],\n",
      " |          defaults to 0.\n",
      " |      axis : {0 or 'index', 1 or 'columns', None}, default 0\n",
      " |          Apply to each column (``axis=0`` or ``'index'``), to each row\n",
      " |          (``axis=1`` or ``'columns'``), or to the entire DataFrame at once\n",
      " |          with ``axis=None``.\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      text_color_threshold : float or int\n",
      " |          This argument is ignored (only used in `background_gradient`).\n",
      " |          Luminance threshold for determining text color in [0, 1]. Facilitates text\n",
      " |          visibility across varying background colors. All text is dark if 0, and\n",
      " |          light if 1, defaults to 0.408.\n",
      " |      vmin : float, optional\n",
      " |          Minimum data value that corresponds to colormap minimum value.\n",
      " |          If not specified the minimum value of the data (or gmap) will be used.\n",
      " |      \n",
      " |          .. versionadded:: 1.0.0\n",
      " |      \n",
      " |      vmax : float, optional\n",
      " |          Maximum data value that corresponds to colormap maximum value.\n",
      " |          If not specified the maximum value of the data (or gmap) will be used.\n",
      " |      \n",
      " |          .. versionadded:: 1.0.0\n",
      " |      \n",
      " |      gmap : array-like, optional\n",
      " |          Gradient map for determining the text colors. If not supplied\n",
      " |          will use the underlying data from rows, columns or frame. If given as an\n",
      " |          ndarray or list-like must be an identical shape to the underlying data\n",
      " |          considering ``axis`` and ``subset``. If given as DataFrame or Series must\n",
      " |          have same index and column labels considering ``axis`` and ``subset``.\n",
      " |          If supplied, ``vmin`` and ``vmax`` should be given relative to this\n",
      " |          gradient map.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.background_gradient: Color the background in a gradient style.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      When using ``low`` and ``high`` the range\n",
      " |      of the gradient, given by the data if ``gmap`` is not given or by ``gmap``,\n",
      " |      is extended at the low end effectively by\n",
      " |      `map.min - low * map.range` and at the high end by\n",
      " |      `map.max + high * map.range` before the colors are normalized and determined.\n",
      " |      \n",
      " |      If combining with ``vmin`` and ``vmax`` the `map.min`, `map.max` and\n",
      " |      `map.range` are replaced by values according to the values derived from\n",
      " |      ``vmin`` and ``vmax``.\n",
      " |      \n",
      " |      This method will preselect numeric columns and ignore non-numeric columns\n",
      " |      unless a ``gmap`` is supplied in which case no preselection occurs.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      >>> df = pd.DataFrame(columns=[\"City\", \"Temp (c)\", \"Rain (mm)\", \"Wind (m/s)\"],\n",
      " |      ...                   data=[[\"Stockholm\", 21.6, 5.0, 3.2],\n",
      " |      ...                         [\"Oslo\", 22.4, 13.3, 3.1],\n",
      " |      ...                         [\"Copenhagen\", 24.5, 0.0, 6.7]])\n",
      " |      \n",
      " |      Shading the values column-wise, with ``axis=0``, preselecting numeric columns\n",
      " |      \n",
      " |      >>> df.style.text_gradient(axis=0)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/tg_ax0.png\n",
      " |      \n",
      " |      Shading all values collectively using ``axis=None``\n",
      " |      \n",
      " |      >>> df.style.text_gradient(axis=None)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/tg_axNone.png\n",
      " |      \n",
      " |      Compress the color map from the both ``low`` and ``high`` ends\n",
      " |      \n",
      " |      >>> df.style.text_gradient(axis=None, low=0.75, high=1.0)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/tg_axNone_lowhigh.png\n",
      " |      \n",
      " |      Manually setting ``vmin`` and ``vmax`` gradient thresholds\n",
      " |      \n",
      " |      >>> df.style.text_gradient(axis=None, vmin=6.7, vmax=21.6)  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/tg_axNone_vminvmax.png\n",
      " |      \n",
      " |      Setting a ``gmap`` and applying to all columns with another ``cmap``\n",
      " |      \n",
      " |      >>> df.style.text_gradient(axis=0, gmap=df['Temp (c)'], cmap='YlOrRd')\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/tg_gmap.png\n",
      " |      \n",
      " |      Setting the gradient map for a dataframe (i.e. ``axis=None``), we need to\n",
      " |      explicitly state ``subset`` to match the ``gmap`` shape\n",
      " |      \n",
      " |      >>> gmap = np.array([[1,2,3], [2,3,4], [3,4,5]])\n",
      " |      >>> df.style.text_gradient(axis=None, gmap=gmap,\n",
      " |      ...     cmap='YlOrRd', subset=['Temp (c)', 'Rain (mm)', 'Wind (m/s)']\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/tg_axNone_gmap.png\n",
      " |  \n",
      " |  to_excel(self, excel_writer, sheet_name: 'str' = 'Sheet1', na_rep: 'str' = '', float_format: 'str | None' = None, columns: 'Sequence[Hashable] | None' = None, header: 'Sequence[Hashable] | bool' = True, index: 'bool' = True, index_label: 'IndexLabel | None' = None, startrow: 'int' = 0, startcol: 'int' = 0, engine: 'str | None' = None, merge_cells: 'bool' = True, encoding: 'str | None' = None, inf_rep: 'str' = 'inf', verbose: 'bool' = True, freeze_panes: 'tuple[int, int] | None' = None) -> 'None'\n",
      " |      Write Styler to an Excel sheet.\n",
      " |      \n",
      " |      To write a single Styler to an Excel .xlsx file it is only necessary to\n",
      " |      specify a target file name. To write to multiple sheets it is necessary to\n",
      " |      create an `ExcelWriter` object with a target file name, and specify a sheet\n",
      " |      in the file to write to.\n",
      " |      \n",
      " |      Multiple sheets may be written to by specifying unique `sheet_name`.\n",
      " |      With all data written to the file it is necessary to save the changes.\n",
      " |      Note that creating an `ExcelWriter` object with a file name that already\n",
      " |      exists will result in the contents of the existing file being erased.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      excel_writer : path-like, file-like, or ExcelWriter object\n",
      " |          File path or existing ExcelWriter.\n",
      " |      sheet_name : str, default 'Sheet1'\n",
      " |          Name of sheet which will contain DataFrame.\n",
      " |      na_rep : str, default ''\n",
      " |          Missing data representation.\n",
      " |      float_format : str, optional\n",
      " |          Format string for floating point numbers. For example\n",
      " |          ``float_format=\"%.2f\"`` will format 0.1234 to 0.12.\n",
      " |      columns : sequence or list of str, optional\n",
      " |          Columns to write.\n",
      " |      header : bool or list of str, default True\n",
      " |          Write out the column names. If a list of string is given it is\n",
      " |          assumed to be aliases for the column names.\n",
      " |      index : bool, default True\n",
      " |          Write row names (index).\n",
      " |      index_label : str or sequence, optional\n",
      " |          Column label for index column(s) if desired. If not specified, and\n",
      " |          `header` and `index` are True, then the index names are used. A\n",
      " |          sequence should be given if the DataFrame uses MultiIndex.\n",
      " |      startrow : int, default 0\n",
      " |          Upper left cell row to dump data frame.\n",
      " |      startcol : int, default 0\n",
      " |          Upper left cell column to dump data frame.\n",
      " |      engine : str, optional\n",
      " |          Write engine to use, 'openpyxl' or 'xlsxwriter'. You can also set this\n",
      " |          via the options ``io.excel.xlsx.writer``, ``io.excel.xls.writer``, and\n",
      " |          ``io.excel.xlsm.writer``.\n",
      " |      \n",
      " |          .. deprecated:: 1.2.0\n",
      " |      \n",
      " |              As the `xlwt <https://pypi.org/project/xlwt/>`__ package is no longer\n",
      " |              maintained, the ``xlwt`` engine will be removed in a future version\n",
      " |              of pandas.\n",
      " |      \n",
      " |      merge_cells : bool, default True\n",
      " |          Write MultiIndex and Hierarchical Rows as merged cells.\n",
      " |      encoding : str, optional\n",
      " |          Encoding of the resulting excel file. Only necessary for xlwt,\n",
      " |          other writers support unicode natively.\n",
      " |      inf_rep : str, default 'inf'\n",
      " |          Representation for infinity (there is no native representation for\n",
      " |          infinity in Excel).\n",
      " |      verbose : bool, default True\n",
      " |          Display more information in the error logs.\n",
      " |      freeze_panes : tuple of int (length 2), optional\n",
      " |          Specifies the one-based bottommost row and rightmost column that\n",
      " |          is to be frozen.\n",
      " |      storage_options : dict, optional\n",
      " |          Extra options that make sense for a particular storage connection, e.g.\n",
      " |          host, port, username, password, etc. For HTTP(S) URLs the key-value pairs\n",
      " |          are forwarded to ``urllib`` as header options. For other URLs (e.g.\n",
      " |          starting with \"s3://\", and \"gcs://\") the key-value pairs are forwarded to\n",
      " |          ``fsspec``. Please see ``fsspec`` and ``urllib`` for more details.\n",
      " |      \n",
      " |          .. versionadded:: 1.2.0\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      to_csv : Write DataFrame to a comma-separated values (csv) file.\n",
      " |      ExcelWriter : Class for writing DataFrame objects into excel sheets.\n",
      " |      read_excel : Read an Excel file into a pandas DataFrame.\n",
      " |      read_csv : Read a comma-separated values (csv) file into DataFrame.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      For compatibility with :meth:`~DataFrame.to_csv`,\n",
      " |      to_excel serializes lists and dicts to strings before writing.\n",
      " |      \n",
      " |      Once a workbook has been saved it is not possible to write further\n",
      " |      data without rewriting the whole workbook.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      \n",
      " |      Create, write to and save a workbook:\n",
      " |      \n",
      " |      >>> df1 = pd.DataFrame([['a', 'b'], ['c', 'd']],\n",
      " |      ...                    index=['row 1', 'row 2'],\n",
      " |      ...                    columns=['col 1', 'col 2'])\n",
      " |      >>> df1.to_excel(\"output.xlsx\")  # doctest: +SKIP\n",
      " |      \n",
      " |      To specify the sheet name:\n",
      " |      \n",
      " |      >>> df1.to_excel(\"output.xlsx\",\n",
      " |      ...              sheet_name='Sheet_name_1')  # doctest: +SKIP\n",
      " |      \n",
      " |      If you wish to write to more than one sheet in the workbook, it is\n",
      " |      necessary to specify an ExcelWriter object:\n",
      " |      \n",
      " |      >>> df2 = df1.copy()\n",
      " |      >>> with pd.ExcelWriter('output.xlsx') as writer:  # doctest: +SKIP\n",
      " |      ...     df1.to_excel(writer, sheet_name='Sheet_name_1')\n",
      " |      ...     df2.to_excel(writer, sheet_name='Sheet_name_2')\n",
      " |      \n",
      " |      ExcelWriter can also be used to append to an existing Excel file:\n",
      " |      \n",
      " |      >>> with pd.ExcelWriter('output.xlsx',\n",
      " |      ...                     mode='a') as writer:  # doctest: +SKIP\n",
      " |      ...     df.to_excel(writer, sheet_name='Sheet_name_3')\n",
      " |      \n",
      " |      To set the library that is used to write the Excel file,\n",
      " |      you can pass the `engine` keyword (the default engine is\n",
      " |      automatically chosen depending on the file extension):\n",
      " |      \n",
      " |      >>> df1.to_excel('output1.xlsx', engine='xlsxwriter')  # doctest: +SKIP\n",
      " |  \n",
      " |  to_html(self, buf: 'FilePath | WriteBuffer[str] | None' = None, *, table_uuid: 'str | None' = None, table_attributes: 'str | None' = None, sparse_index: 'bool | None' = None, sparse_columns: 'bool | None' = None, bold_headers: 'bool' = False, caption: 'str | None' = None, max_rows: 'int | None' = None, max_columns: 'int | None' = None, encoding: 'str | None' = None, doctype_html: 'bool' = False, exclude_styles: 'bool' = False, **kwargs)\n",
      " |      Write Styler to a file, buffer or string in HTML-CSS format.\n",
      " |      \n",
      " |      .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      buf : str, path object, file-like object, or None, default None\n",
      " |          String, path object (implementing ``os.PathLike[str]``), or file-like\n",
      " |          object implementing a string ``write()`` function. If None, the result is\n",
      " |          returned as a string.\n",
      " |      table_uuid : str, optional\n",
      " |          Id attribute assigned to the <table> HTML element in the format:\n",
      " |      \n",
      " |          ``<table id=\"T_<table_uuid>\" ..>``\n",
      " |      \n",
      " |          If not given uses Styler's initially assigned value.\n",
      " |      table_attributes : str, optional\n",
      " |          Attributes to assign within the `<table>` HTML element in the format:\n",
      " |      \n",
      " |          ``<table .. <table_attributes> >``\n",
      " |      \n",
      " |          If not given defaults to Styler's preexisting value.\n",
      " |      sparse_index : bool, optional\n",
      " |          Whether to sparsify the display of a hierarchical index. Setting to False\n",
      " |          will display each explicit level element in a hierarchical key for each row.\n",
      " |          Defaults to ``pandas.options.styler.sparse.index`` value.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      sparse_columns : bool, optional\n",
      " |          Whether to sparsify the display of a hierarchical index. Setting to False\n",
      " |          will display each explicit level element in a hierarchical key for each\n",
      " |          column. Defaults to ``pandas.options.styler.sparse.columns`` value.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      bold_headers : bool, optional\n",
      " |          Adds \"font-weight: bold;\" as a CSS property to table style header cells.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      caption : str, optional\n",
      " |          Set, or overwrite, the caption on Styler before rendering.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      max_rows : int, optional\n",
      " |          The maximum number of rows that will be rendered. Defaults to\n",
      " |          ``pandas.options.styler.render.max_rows/max_columns``.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      max_columns : int, optional\n",
      " |          The maximum number of columns that will be rendered. Defaults to\n",
      " |          ``pandas.options.styler.render.max_columns``, which is None.\n",
      " |      \n",
      " |          Rows and columns may be reduced if the number of total elements is\n",
      " |          large. This value is set to ``pandas.options.styler.render.max_elements``,\n",
      " |          which is 262144 (18 bit browser rendering).\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      encoding : str, optional\n",
      " |          Character encoding setting for file output, and HTML meta tags.\n",
      " |          Defaults to ``pandas.options.styler.render.encoding`` value of \"utf-8\".\n",
      " |      doctype_html : bool, default False\n",
      " |          Whether to output a fully structured HTML file including all\n",
      " |          HTML elements, or just the core ``<style>`` and ``<table>`` elements.\n",
      " |      exclude_styles : bool, default False\n",
      " |          Whether to include the ``<style>`` element and all associated element\n",
      " |          ``class`` and ``id`` identifiers, or solely the ``<table>`` element without\n",
      " |          styling identifiers.\n",
      " |      **kwargs\n",
      " |          Any additional keyword arguments are passed through to the jinja2\n",
      " |          ``self.template.render`` process. This is useful when you need to provide\n",
      " |          additional variables for a custom template.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      str or None\n",
      " |          If `buf` is None, returns the result as a string. Otherwise returns `None`.\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      DataFrame.to_html: Write a DataFrame to a file, buffer or string in HTML format.\n",
      " |  \n",
      " |  to_latex(self, buf: 'FilePath | WriteBuffer[str] | None' = None, *, column_format: 'str | None' = None, position: 'str | None' = None, position_float: 'str | None' = None, hrules: 'bool | None' = None, clines: 'str | None' = None, label: 'str | None' = None, caption: 'str | tuple | None' = None, sparse_index: 'bool | None' = None, sparse_columns: 'bool | None' = None, multirow_align: 'str | None' = None, multicol_align: 'str | None' = None, siunitx: 'bool' = False, environment: 'str | None' = None, encoding: 'str | None' = None, convert_css: 'bool' = False)\n",
      " |      Write Styler to a file, buffer or string in LaTeX format.\n",
      " |      \n",
      " |      .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      buf : str, path object, file-like object, or None, default None\n",
      " |          String, path object (implementing ``os.PathLike[str]``), or file-like\n",
      " |          object implementing a string ``write()`` function. If None, the result is\n",
      " |          returned as a string.\n",
      " |      column_format : str, optional\n",
      " |          The LaTeX column specification placed in location:\n",
      " |      \n",
      " |          \\\\begin{tabular}{<column_format>}\n",
      " |      \n",
      " |          Defaults to 'l' for index and\n",
      " |          non-numeric data columns, and, for numeric data columns,\n",
      " |          to 'r' by default, or 'S' if ``siunitx`` is ``True``.\n",
      " |      position : str, optional\n",
      " |          The LaTeX positional argument (e.g. 'h!') for tables, placed in location:\n",
      " |      \n",
      " |          ``\\\\begin{table}[<position>]``.\n",
      " |      position_float : {\"centering\", \"raggedleft\", \"raggedright\"}, optional\n",
      " |          The LaTeX float command placed in location:\n",
      " |      \n",
      " |          \\\\begin{table}[<position>]\n",
      " |      \n",
      " |          \\\\<position_float>\n",
      " |      \n",
      " |          Cannot be used if ``environment`` is \"longtable\".\n",
      " |      hrules : bool\n",
      " |          Set to `True` to add \\\\toprule, \\\\midrule and \\\\bottomrule from the\n",
      " |          {booktabs} LaTeX package.\n",
      " |          Defaults to ``pandas.options.styler.latex.hrules``, which is `False`.\n",
      " |      \n",
      " |          .. versionchanged:: 1.4.0\n",
      " |      clines : str, optional\n",
      " |          Use to control adding \\\\cline commands for the index labels separation.\n",
      " |          Possible values are:\n",
      " |      \n",
      " |            - `None`: no cline commands are added (default).\n",
      " |            - `\"all;data\"`: a cline is added for every index value extending the\n",
      " |              width of the table, including data entries.\n",
      " |            - `\"all;index\"`: as above with lines extending only the width of the\n",
      " |              index entries.\n",
      " |            - `\"skip-last;data\"`: a cline is added for each index value except the\n",
      " |              last level (which is never sparsified), extending the widtn of the\n",
      " |              table.\n",
      " |            - `\"skip-last;index\"`: as above with lines extending only the width of the\n",
      " |              index entries.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      label : str, optional\n",
      " |          The LaTeX label included as: \\\\label{<label>}.\n",
      " |          This is used with \\\\ref{<label>} in the main .tex file.\n",
      " |      caption : str, tuple, optional\n",
      " |          If string, the LaTeX table caption included as: \\\\caption{<caption>}.\n",
      " |          If tuple, i.e (\"full caption\", \"short caption\"), the caption included\n",
      " |          as: \\\\caption[<caption[1]>]{<caption[0]>}.\n",
      " |      sparse_index : bool, optional\n",
      " |          Whether to sparsify the display of a hierarchical index. Setting to False\n",
      " |          will display each explicit level element in a hierarchical key for each row.\n",
      " |          Defaults to ``pandas.options.styler.sparse.index``, which is `True`.\n",
      " |      sparse_columns : bool, optional\n",
      " |          Whether to sparsify the display of a hierarchical index. Setting to False\n",
      " |          will display each explicit level element in a hierarchical key for each\n",
      " |          column. Defaults to ``pandas.options.styler.sparse.columns``, which\n",
      " |          is `True`.\n",
      " |      multirow_align : {\"c\", \"t\", \"b\", \"naive\"}, optional\n",
      " |          If sparsifying hierarchical MultiIndexes whether to align text centrally,\n",
      " |          at the top or bottom using the multirow package. If not given defaults to\n",
      " |          ``pandas.options.styler.latex.multirow_align``, which is `\"c\"`.\n",
      " |          If \"naive\" is given renders without multirow.\n",
      " |      \n",
      " |          .. versionchanged:: 1.4.0\n",
      " |      multicol_align : {\"r\", \"c\", \"l\", \"naive-l\", \"naive-r\"}, optional\n",
      " |          If sparsifying hierarchical MultiIndex columns whether to align text at\n",
      " |          the left, centrally, or at the right. If not given defaults to\n",
      " |          ``pandas.options.styler.latex.multicol_align``, which is \"r\".\n",
      " |          If a naive option is given renders without multicol.\n",
      " |          Pipe decorators can also be added to non-naive values to draw vertical\n",
      " |          rules, e.g. \"\\|r\" will draw a rule on the left side of right aligned merged\n",
      " |          cells.\n",
      " |      \n",
      " |          .. versionchanged:: 1.4.0\n",
      " |      siunitx : bool, default False\n",
      " |          Set to ``True`` to structure LaTeX compatible with the {siunitx} package.\n",
      " |      environment : str, optional\n",
      " |          If given, the environment that will replace 'table' in ``\\\\begin{table}``.\n",
      " |          If 'longtable' is specified then a more suitable template is\n",
      " |          rendered. If not given defaults to\n",
      " |          ``pandas.options.styler.latex.environment``, which is `None`.\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      encoding : str, optional\n",
      " |          Character encoding setting. Defaults\n",
      " |          to ``pandas.options.styler.render.encoding``, which is \"utf-8\".\n",
      " |      convert_css : bool, default False\n",
      " |          Convert simple cell-styles from CSS to LaTeX format. Any CSS not found in\n",
      " |          conversion table is dropped. A style can be forced by adding option\n",
      " |          `--latex`. See notes.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      str or None\n",
      " |          If `buf` is None, returns the result as a string. Otherwise returns `None`.\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.format: Format the text display value of cells.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      **Latex Packages**\n",
      " |      \n",
      " |      For the following features we recommend the following LaTeX inclusions:\n",
      " |      \n",
      " |      ===================== ==========================================================\n",
      " |      Feature               Inclusion\n",
      " |      ===================== ==========================================================\n",
      " |      sparse columns        none: included within default {tabular} environment\n",
      " |      sparse rows           \\\\usepackage{multirow}\n",
      " |      hrules                \\\\usepackage{booktabs}\n",
      " |      colors                \\\\usepackage[table]{xcolor}\n",
      " |      siunitx               \\\\usepackage{siunitx}\n",
      " |      bold (with siunitx)   | \\\\usepackage{etoolbox}\n",
      " |                            | \\\\robustify\\\\bfseries\n",
      " |                            | \\\\sisetup{detect-all = true}  *(within {document})*\n",
      " |      italic (with siunitx) | \\\\usepackage{etoolbox}\n",
      " |                            | \\\\robustify\\\\itshape\n",
      " |                            | \\\\sisetup{detect-all = true}  *(within {document})*\n",
      " |      environment           \\\\usepackage{longtable} if arg is \"longtable\"\n",
      " |                            | or any other relevant environment package\n",
      " |      hyperlinks            \\\\usepackage{hyperref}\n",
      " |      ===================== ==========================================================\n",
      " |      \n",
      " |      **Cell Styles**\n",
      " |      \n",
      " |      LaTeX styling can only be rendered if the accompanying styling functions have\n",
      " |      been constructed with appropriate LaTeX commands. All styling\n",
      " |      functionality is built around the concept of a CSS ``(<attribute>, <value>)``\n",
      " |      pair (see `Table Visualization <../../user_guide/style.ipynb>`_), and this\n",
      " |      should be replaced by a LaTeX\n",
      " |      ``(<command>, <options>)`` approach. Each cell will be styled individually\n",
      " |      using nested LaTeX commands with their accompanied options.\n",
      " |      \n",
      " |      For example the following code will highlight and bold a cell in HTML-CSS:\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1,2], [3,4]])\n",
      " |      >>> s = df.style.highlight_max(axis=None,\n",
      " |      ...                            props='background-color:red; font-weight:bold;')\n",
      " |      >>> s.to_html()  # doctest: +SKIP\n",
      " |      \n",
      " |      The equivalent using LaTeX only commands is the following:\n",
      " |      \n",
      " |      >>> s = df.style.highlight_max(axis=None,\n",
      " |      ...                            props='cellcolor:{red}; bfseries: ;')\n",
      " |      >>> s.to_latex()  # doctest: +SKIP\n",
      " |      \n",
      " |      Internally these structured LaTeX ``(<command>, <options>)`` pairs\n",
      " |      are translated to the\n",
      " |      ``display_value`` with the default structure:\n",
      " |      ``\\<command><options> <display_value>``.\n",
      " |      Where there are multiple commands the latter is nested recursively, so that\n",
      " |      the above example highlighed cell is rendered as\n",
      " |      ``\\cellcolor{red} \\bfseries 4``.\n",
      " |      \n",
      " |      Occasionally this format does not suit the applied command, or\n",
      " |      combination of LaTeX packages that is in use, so additional flags can be\n",
      " |      added to the ``<options>``, within the tuple, to result in different\n",
      " |      positions of required braces (the **default** being the same as ``--nowrap``):\n",
      " |      \n",
      " |      =================================== ============================================\n",
      " |      Tuple Format                           Output Structure\n",
      " |      =================================== ============================================\n",
      " |      (<command>,<options>)               \\\\<command><options> <display_value>\n",
      " |      (<command>,<options> ``--nowrap``)  \\\\<command><options> <display_value>\n",
      " |      (<command>,<options> ``--rwrap``)   \\\\<command><options>{<display_value>}\n",
      " |      (<command>,<options> ``--wrap``)    {\\\\<command><options> <display_value>}\n",
      " |      (<command>,<options> ``--lwrap``)   {\\\\<command><options>} <display_value>\n",
      " |      (<command>,<options> ``--dwrap``)   {\\\\<command><options>}{<display_value>}\n",
      " |      =================================== ============================================\n",
      " |      \n",
      " |      For example the `textbf` command for font-weight\n",
      " |      should always be used with `--rwrap` so ``('textbf', '--rwrap')`` will render a\n",
      " |      working cell, wrapped with braces, as ``\\textbf{<display_value>}``.\n",
      " |      \n",
      " |      A more comprehensive example is as follows:\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2.2, \"dogs\"], [3, 4.4, \"cats\"], [2, 6.6, \"cows\"]],\n",
      " |      ...                   index=[\"ix1\", \"ix2\", \"ix3\"],\n",
      " |      ...                   columns=[\"Integers\", \"Floats\", \"Strings\"])\n",
      " |      >>> s = df.style.highlight_max(\n",
      " |      ...     props='cellcolor:[HTML]{FFFF00}; color:{red};'\n",
      " |      ...           'textit:--rwrap; textbf:--rwrap;'\n",
      " |      ... )\n",
      " |      >>> s.to_latex()  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/latex_1.png\n",
      " |      \n",
      " |      **Table Styles**\n",
      " |      \n",
      " |      Internally Styler uses its ``table_styles`` object to parse the\n",
      " |      ``column_format``, ``position``, ``position_float``, and ``label``\n",
      " |      input arguments. These arguments are added to table styles in the format:\n",
      " |      \n",
      " |      .. code-block:: python\n",
      " |      \n",
      " |          set_table_styles([\n",
      " |              {\"selector\": \"column_format\", \"props\": f\":{column_format};\"},\n",
      " |              {\"selector\": \"position\", \"props\": f\":{position};\"},\n",
      " |              {\"selector\": \"position_float\", \"props\": f\":{position_float};\"},\n",
      " |              {\"selector\": \"label\", \"props\": f\":{{{label.replace(':','§')}}};\"}\n",
      " |          ], overwrite=False)\n",
      " |      \n",
      " |      Exception is made for the ``hrules`` argument which, in fact, controls all three\n",
      " |      commands: ``toprule``, ``bottomrule`` and ``midrule`` simultaneously. Instead of\n",
      " |      setting ``hrules`` to ``True``, it is also possible to set each\n",
      " |      individual rule definition, by manually setting the ``table_styles``,\n",
      " |      for example below we set a regular ``toprule``, set an ``hline`` for\n",
      " |      ``bottomrule`` and exclude the ``midrule``:\n",
      " |      \n",
      " |      .. code-block:: python\n",
      " |      \n",
      " |          set_table_styles([\n",
      " |              {'selector': 'toprule', 'props': ':toprule;'},\n",
      " |              {'selector': 'bottomrule', 'props': ':hline;'},\n",
      " |          ], overwrite=False)\n",
      " |      \n",
      " |      If other ``commands`` are added to table styles they will be detected, and\n",
      " |      positioned immediately above the '\\\\begin{tabular}' command. For example to\n",
      " |      add odd and even row coloring, from the {colortbl} package, in format\n",
      " |      ``\\rowcolors{1}{pink}{red}``, use:\n",
      " |      \n",
      " |      .. code-block:: python\n",
      " |      \n",
      " |          set_table_styles([\n",
      " |              {'selector': 'rowcolors', 'props': ':{1}{pink}{red};'}\n",
      " |          ], overwrite=False)\n",
      " |      \n",
      " |      A more comprehensive example using these arguments is as follows:\n",
      " |      \n",
      " |      >>> df.columns = pd.MultiIndex.from_tuples([\n",
      " |      ...     (\"Numeric\", \"Integers\"),\n",
      " |      ...     (\"Numeric\", \"Floats\"),\n",
      " |      ...     (\"Non-Numeric\", \"Strings\")\n",
      " |      ... ])\n",
      " |      >>> df.index = pd.MultiIndex.from_tuples([\n",
      " |      ...     (\"L0\", \"ix1\"), (\"L0\", \"ix2\"), (\"L1\", \"ix3\")\n",
      " |      ... ])\n",
      " |      >>> s = df.style.highlight_max(\n",
      " |      ...     props='cellcolor:[HTML]{FFFF00}; color:{red}; itshape:; bfseries:;'\n",
      " |      ... )\n",
      " |      >>> s.to_latex(\n",
      " |      ...     column_format=\"rrrrr\", position=\"h\", position_float=\"centering\",\n",
      " |      ...     hrules=True, label=\"table:5\", caption=\"Styled LaTeX Table\",\n",
      " |      ...     multirow_align=\"t\", multicol_align=\"r\"\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/latex_2.png\n",
      " |      \n",
      " |      **Formatting**\n",
      " |      \n",
      " |      To format values :meth:`Styler.format` should be used prior to calling\n",
      " |      `Styler.to_latex`, as well as other methods such as :meth:`Styler.hide`\n",
      " |      for example:\n",
      " |      \n",
      " |      >>> s.clear()\n",
      " |      >>> s.table_styles = []\n",
      " |      >>> s.caption = None\n",
      " |      >>> s.format({\n",
      " |      ...    (\"Numeric\", \"Integers\"): '\\${}',\n",
      " |      ...    (\"Numeric\", \"Floats\"): '{:.3f}',\n",
      " |      ...    (\"Non-Numeric\", \"Strings\"): str.upper\n",
      " |      ... })  # doctest: +SKIP\n",
      " |                      Numeric      Non-Numeric\n",
      " |                Integers   Floats    Strings\n",
      " |      L0    ix1       $1   2.200      DOGS\n",
      " |            ix2       $3   4.400      CATS\n",
      " |      L1    ix3       $2   6.600      COWS\n",
      " |      \n",
      " |      >>> s.to_latex()  # doctest: +SKIP\n",
      " |      \\begin{tabular}{llrrl}\n",
      " |      {} & {} & \\multicolumn{2}{r}{Numeric} & {Non-Numeric} \\\\\n",
      " |      {} & {} & {Integers} & {Floats} & {Strings} \\\\\n",
      " |      \\multirow[c]{2}{*}{L0} & ix1 & \\\\$1 & 2.200 & DOGS \\\\\n",
      " |       & ix2 & \\$3 & 4.400 & CATS \\\\\n",
      " |      L1 & ix3 & \\$2 & 6.600 & COWS \\\\\n",
      " |      \\end{tabular}\n",
      " |      \n",
      " |      **CSS Conversion**\n",
      " |      \n",
      " |      This method can convert a Styler constructured with HTML-CSS to LaTeX using\n",
      " |      the following limited conversions.\n",
      " |      \n",
      " |      ================== ==================== ============= ==========================\n",
      " |      CSS Attribute      CSS value            LaTeX Command LaTeX Options\n",
      " |      ================== ==================== ============= ==========================\n",
      " |      font-weight        | bold               | bfseries\n",
      " |                         | bolder             | bfseries\n",
      " |      font-style         | italic             | itshape\n",
      " |                         | oblique            | slshape\n",
      " |      background-color   | red                cellcolor     | {red}--lwrap\n",
      " |                         | #fe01ea                          | [HTML]{FE01EA}--lwrap\n",
      " |                         | #f0e                             | [HTML]{FF00EE}--lwrap\n",
      " |                         | rgb(128,255,0)                   | [rgb]{0.5,1,0}--lwrap\n",
      " |                         | rgba(128,0,0,0.5)                | [rgb]{0.5,0,0}--lwrap\n",
      " |                         | rgb(25%,255,50%)                 | [rgb]{0.25,1,0.5}--lwrap\n",
      " |      color              | red                color         | {red}\n",
      " |                         | #fe01ea                          | [HTML]{FE01EA}\n",
      " |                         | #f0e                             | [HTML]{FF00EE}\n",
      " |                         | rgb(128,255,0)                   | [rgb]{0.5,1,0}\n",
      " |                         | rgba(128,0,0,0.5)                | [rgb]{0.5,0,0}\n",
      " |                         | rgb(25%,255,50%)                 | [rgb]{0.25,1,0.5}\n",
      " |      ================== ==================== ============= ==========================\n",
      " |      \n",
      " |      It is also possible to add user-defined LaTeX only styles to a HTML-CSS Styler\n",
      " |      using the ``--latex`` flag, and to add LaTeX parsing options that the\n",
      " |      converter will detect within a CSS-comment.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1]])\n",
      " |      >>> df.style.set_properties(\n",
      " |      ...     **{\"font-weight\": \"bold /* --dwrap */\", \"Huge\": \"--latex--rwrap\"}\n",
      " |      ... ).to_latex(convert_css=True)  # doctest: +SKIP\n",
      " |      \\begin{tabular}{lr}\n",
      " |      {} & {0} \\\\\n",
      " |      0 & {\\bfseries}{\\Huge{1}} \\\\\n",
      " |      \\end{tabular}\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Below we give a complete step by step example adding some advanced features\n",
      " |      and noting some common gotchas.\n",
      " |      \n",
      " |      First we create the DataFrame and Styler as usual, including MultiIndex rows\n",
      " |      and columns, which allow for more advanced formatting options:\n",
      " |      \n",
      " |      >>> cidx = pd.MultiIndex.from_arrays([\n",
      " |      ...     [\"Equity\", \"Equity\", \"Equity\", \"Equity\",\n",
      " |      ...      \"Stats\", \"Stats\", \"Stats\", \"Stats\", \"Rating\"],\n",
      " |      ...     [\"Energy\", \"Energy\", \"Consumer\", \"Consumer\", \"\", \"\", \"\", \"\", \"\"],\n",
      " |      ...     [\"BP\", \"Shell\", \"H&M\", \"Unilever\",\n",
      " |      ...      \"Std Dev\", \"Variance\", \"52w High\", \"52w Low\", \"\"]\n",
      " |      ... ])\n",
      " |      >>> iidx = pd.MultiIndex.from_arrays([\n",
      " |      ...     [\"Equity\", \"Equity\", \"Equity\", \"Equity\"],\n",
      " |      ...     [\"Energy\", \"Energy\", \"Consumer\", \"Consumer\"],\n",
      " |      ...     [\"BP\", \"Shell\", \"H&M\", \"Unilever\"]\n",
      " |      ... ])\n",
      " |      >>> styler = pd.DataFrame([\n",
      " |      ...     [1, 0.8, 0.66, 0.72, 32.1678, 32.1678**2, 335.12, 240.89, \"Buy\"],\n",
      " |      ...     [0.8, 1.0, 0.69, 0.79, 1.876, 1.876**2, 14.12, 19.78, \"Hold\"],\n",
      " |      ...     [0.66, 0.69, 1.0, 0.86, 7, 7**2, 210.9, 140.6, \"Buy\"],\n",
      " |      ...     [0.72, 0.79, 0.86, 1.0, 213.76, 213.76**2, 2807, 3678, \"Sell\"],\n",
      " |      ... ], columns=cidx, index=iidx).style\n",
      " |      \n",
      " |      Second we will format the display and, since our table is quite wide, will\n",
      " |      hide the repeated level-0 of the index:\n",
      " |      \n",
      " |      >>> styler.format(subset=\"Equity\", precision=2)\n",
      " |      ...       .format(subset=\"Stats\", precision=1, thousands=\",\")\n",
      " |      ...       .format(subset=\"Rating\", formatter=str.upper)\n",
      " |      ...       .format_index(escape=\"latex\", axis=1)\n",
      " |      ...       .format_index(escape=\"latex\", axis=0)\n",
      " |      ...       .hide(level=0, axis=0)  # doctest: +SKIP\n",
      " |      \n",
      " |      Note that one of the string entries of the index and column headers is \"H&M\".\n",
      " |      Without applying the `escape=\"latex\"` option to the `format_index` method the\n",
      " |      resultant LaTeX will fail to render, and the error returned is quite\n",
      " |      difficult to debug. Using the appropriate escape the \"&\" is converted to \"\\\\&\".\n",
      " |      \n",
      " |      Thirdly we will apply some (CSS-HTML) styles to our object. We will use a\n",
      " |      builtin method and also define our own method to highlight the stock\n",
      " |      recommendation:\n",
      " |      \n",
      " |      >>> def rating_color(v):\n",
      " |      ...     if v == \"Buy\": color = \"#33ff85\"\n",
      " |      ...     elif v == \"Sell\": color = \"#ff5933\"\n",
      " |      ...     else: color = \"#ffdd33\"\n",
      " |      ...     return f\"color: {color}; font-weight: bold;\"\n",
      " |      >>> styler.background_gradient(cmap=\"inferno\", subset=\"Equity\", vmin=0, vmax=1)\n",
      " |      ...       .applymap(rating_color, subset=\"Rating\")  # doctest: +SKIP\n",
      " |      \n",
      " |      All the above styles will work with HTML (see below) and LaTeX upon conversion:\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/latex_stocks_html.png\n",
      " |      \n",
      " |      However, we finally want to add one LaTeX only style\n",
      " |      (from the {graphicx} package), that is not easy to convert from CSS and\n",
      " |      pandas does not support it. Notice the `--latex` flag used here,\n",
      " |      as well as `--rwrap` to ensure this is formatted correctly and\n",
      " |      not ignored upon conversion.\n",
      " |      \n",
      " |      >>> styler.applymap_index(\n",
      " |      ...     lambda v: \"rotatebox:{45}--rwrap--latex;\", level=2, axis=1\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \n",
      " |      Finally we render our LaTeX adding in other options as required:\n",
      " |      \n",
      " |      >>> styler.to_latex(\n",
      " |      ...     caption=\"Selected stock correlation and simple statistics.\",\n",
      " |      ...     clines=\"skip-last;data\",\n",
      " |      ...     convert_css=True,\n",
      " |      ...     position_float=\"centering\",\n",
      " |      ...     multicol_align=\"|c|\",\n",
      " |      ...     hrules=True,\n",
      " |      ... )  # doctest: +SKIP\n",
      " |      \\begin{table}\n",
      " |      \\centering\n",
      " |      \\caption{Selected stock correlation and simple statistics.}\n",
      " |      \\begin{tabular}{llrrrrrrrrl}\n",
      " |      \\toprule\n",
      " |       &  & \\multicolumn{4}{|c|}{Equity} & \\multicolumn{4}{|c|}{Stats} & Rating \\\\\n",
      " |       &  & \\multicolumn{2}{|c|}{Energy} & \\multicolumn{2}{|c|}{Consumer} &\n",
      " |      \\multicolumn{4}{|c|}{} &  \\\\\n",
      " |       &  & \\rotatebox{45}{BP} & \\rotatebox{45}{Shell} & \\rotatebox{45}{H\\&M} &\n",
      " |      \\rotatebox{45}{Unilever} & \\rotatebox{45}{Std Dev} & \\rotatebox{45}{Variance} &\n",
      " |      \\rotatebox{45}{52w High} & \\rotatebox{45}{52w Low} & \\rotatebox{45}{} \\\\\n",
      " |      \\midrule\n",
      " |      \\multirow[c]{2}{*}{Energy} & BP & {\\cellcolor[HTML]{FCFFA4}}\n",
      " |      \\color[HTML]{000000} 1.00 & {\\cellcolor[HTML]{FCA50A}} \\color[HTML]{000000}\n",
      " |      0.80 & {\\cellcolor[HTML]{EB6628}} \\color[HTML]{F1F1F1} 0.66 &\n",
      " |      {\\cellcolor[HTML]{F68013}} \\color[HTML]{F1F1F1} 0.72 & 32.2 & 1,034.8 & 335.1\n",
      " |      & 240.9 & \\color[HTML]{33FF85} \\bfseries BUY \\\\\n",
      " |       & Shell & {\\cellcolor[HTML]{FCA50A}} \\color[HTML]{000000} 0.80 &\n",
      " |      {\\cellcolor[HTML]{FCFFA4}} \\color[HTML]{000000} 1.00 &\n",
      " |      {\\cellcolor[HTML]{F1731D}} \\color[HTML]{F1F1F1} 0.69 &\n",
      " |      {\\cellcolor[HTML]{FCA108}} \\color[HTML]{000000} 0.79 & 1.9 & 3.5 & 14.1 &\n",
      " |      19.8 & \\color[HTML]{FFDD33} \\bfseries HOLD \\\\\n",
      " |      \\cline{1-11}\n",
      " |      \\multirow[c]{2}{*}{Consumer} & H\\&M & {\\cellcolor[HTML]{EB6628}}\n",
      " |      \\color[HTML]{F1F1F1} 0.66 & {\\cellcolor[HTML]{F1731D}} \\color[HTML]{F1F1F1}\n",
      " |      0.69 & {\\cellcolor[HTML]{FCFFA4}} \\color[HTML]{000000} 1.00 &\n",
      " |      {\\cellcolor[HTML]{FAC42A}} \\color[HTML]{000000} 0.86 & 7.0 & 49.0 & 210.9 &\n",
      " |      140.6 & \\color[HTML]{33FF85} \\bfseries BUY \\\\\n",
      " |       & Unilever & {\\cellcolor[HTML]{F68013}} \\color[HTML]{F1F1F1} 0.72 &\n",
      " |      {\\cellcolor[HTML]{FCA108}} \\color[HTML]{000000} 0.79 &\n",
      " |      {\\cellcolor[HTML]{FAC42A}} \\color[HTML]{000000} 0.86 &\n",
      " |      {\\cellcolor[HTML]{FCFFA4}} \\color[HTML]{000000} 1.00 & 213.8 & 45,693.3 &\n",
      " |      2,807.0 & 3,678.0 & \\color[HTML]{FF5933} \\bfseries SELL \\\\\n",
      " |      \\cline{1-11}\n",
      " |      \\bottomrule\n",
      " |      \\end{tabular}\n",
      " |      \\end{table}\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/latex_stocks.png\n",
      " |  \n",
      " |  use(self, styles: 'dict[str, Any]') -> 'Styler'\n",
      " |      Set the styles on the current Styler.\n",
      " |      \n",
      " |      Possibly uses styles from ``Styler.export``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      styles : dict(str, Any)\n",
      " |          List of attributes to add to Styler. Dict keys should contain only:\n",
      " |            - \"apply\": list of styler functions, typically added with ``apply`` or\n",
      " |              ``applymap``.\n",
      " |            - \"table_attributes\": HTML attributes, typically added with\n",
      " |              ``set_table_attributes``.\n",
      " |            - \"table_styles\": CSS selectors and properties, typically added with\n",
      " |              ``set_table_styles``.\n",
      " |            - \"hide_index\":  whether the index is hidden, typically added with\n",
      " |              ``hide_index``, or a boolean list for hidden levels.\n",
      " |            - \"hide_columns\": whether column headers are hidden, typically added with\n",
      " |              ``hide_columns``, or a boolean list for hidden levels.\n",
      " |            - \"hide_index_names\": whether index names are hidden.\n",
      " |            - \"hide_column_names\": whether column header names are hidden.\n",
      " |            - \"css\": the css class names used.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.export : Export the non data dependent attributes to the current Styler.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      \n",
      " |      >>> styler = DataFrame([[1, 2], [3, 4]]).style\n",
      " |      >>> styler2 = DataFrame([[9, 9, 9]]).style\n",
      " |      >>> styler.hide(axis=0).highlight_max(axis=1)  # doctest: +SKIP\n",
      " |      >>> export = styler.export()\n",
      " |      >>> styler2.use(export)  # doctest: +SKIP\n",
      " |  \n",
      " |  where(self, cond: 'Callable', value: 'str', other: 'str | None' = None, subset: 'Subset | None' = None, **kwargs) -> 'Styler'\n",
      " |      Apply CSS-styles based on a conditional function elementwise.\n",
      " |      \n",
      " |      .. deprecated:: 1.3.0\n",
      " |      \n",
      " |      Updates the HTML representation with a style which is\n",
      " |      selected in accordance with the return value of a function.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      cond : callable\n",
      " |          ``cond`` should take a scalar, and optional keyword arguments, and return\n",
      " |          a boolean.\n",
      " |      value : str\n",
      " |          Applied when ``cond`` returns true.\n",
      " |      other : str\n",
      " |          Applied when ``cond`` returns false.\n",
      " |      \n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      \n",
      " |      **kwargs : dict\n",
      " |          Pass along to ``cond``.\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.applymap: Apply a CSS-styling function elementwise.\n",
      " |      Styler.apply: Apply a CSS-styling function column-wise, row-wise, or table-wise.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method is deprecated.\n",
      " |      \n",
      " |      This method is a convenience wrapper for :meth:`Styler.applymap`, which we\n",
      " |      recommend using instead.\n",
      " |      \n",
      " |      The example:\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2], [3, 4]])\n",
      " |      >>> def cond(v, limit=4):\n",
      " |      ...     return v > 1 and v != limit\n",
      " |      >>> df.style.where(cond, value='color:green;', other='color:red;')\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      should be refactored to:\n",
      " |      \n",
      " |      >>> def style_func(v, value, other, limit=4):\n",
      " |      ...     cond = v > 1 and v != limit\n",
      " |      ...     return value if cond else other\n",
      " |      >>> df.style.applymap(style_func, value='color:green;', other='color:red;')\n",
      " |      ...  # doctest: +SKIP\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  from_custom_template(searchpath, html_table: 'str | None' = None, html_style: 'str | None' = None) from builtins.type\n",
      " |      Factory function for creating a subclass of ``Styler``.\n",
      " |      \n",
      " |      Uses custom templates and Jinja environment.\n",
      " |      \n",
      " |      .. versionchanged:: 1.3.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      searchpath : str or list\n",
      " |          Path or paths of directories containing the templates.\n",
      " |      html_table : str\n",
      " |          Name of your custom template to replace the html_table template.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      html_style : str\n",
      " |          Name of your custom template to replace the html_style template.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      MyStyler : subclass of Styler\n",
      " |          Has the correct ``env``,``template_html``, ``template_html_table`` and\n",
      " |          ``template_html_style`` class attributes set.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from pandas.io.formats.style_render.StylerRenderer:\n",
      " |  \n",
      " |  format(self, formatter: 'ExtFormatter | None' = None, subset: 'Subset | None' = None, na_rep: 'str | None' = None, precision: 'int | None' = None, decimal: 'str' = '.', thousands: 'str | None' = None, escape: 'str | None' = None, hyperlinks: 'str | None' = None) -> 'StylerRenderer'\n",
      " |      Format the text display value of cells.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      formatter : str, callable, dict or None\n",
      " |          Object to define how values are displayed. See notes.\n",
      " |      subset : label, array-like, IndexSlice, optional\n",
      " |          A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input\n",
      " |          or single key, to `DataFrame.loc[:, <subset>]` where the columns are\n",
      " |          prioritised, to limit ``data`` to *before* applying the function.\n",
      " |      na_rep : str, optional\n",
      " |          Representation for missing values.\n",
      " |          If ``na_rep`` is None, no special formatting is applied.\n",
      " |      \n",
      " |          .. versionadded:: 1.0.0\n",
      " |      \n",
      " |      precision : int, optional\n",
      " |          Floating point precision to use for display purposes, if not determined by\n",
      " |          the specified ``formatter``.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      decimal : str, default \".\"\n",
      " |          Character used as decimal separator for floats, complex and integers.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      thousands : str, optional, default None\n",
      " |          Character used as thousands separator for floats, complex and integers.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      escape : str, optional\n",
      " |          Use 'html' to replace the characters ``&``, ``<``, ``>``, ``'``, and ``\"``\n",
      " |          in cell display string with HTML-safe sequences.\n",
      " |          Use 'latex' to replace the characters ``&``, ``%``, ``$``, ``#``, ``_``,\n",
      " |          ``{``, ``}``, ``~``, ``^``, and ``\\`` in the cell display string with\n",
      " |          LaTeX-safe sequences.\n",
      " |          Escaping is done before ``formatter``.\n",
      " |      \n",
      " |          .. versionadded:: 1.3.0\n",
      " |      \n",
      " |      hyperlinks : {\"html\", \"latex\"}, optional\n",
      " |          Convert string patterns containing https://, http://, ftp:// or www. to\n",
      " |          HTML <a> tags as clickable URL hyperlinks if \"html\", or LaTeX \\href\n",
      " |          commands if \"latex\".\n",
      " |      \n",
      " |          .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.format_index: Format the text display value of index labels.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method assigns a formatting function, ``formatter``, to each cell in the\n",
      " |      DataFrame. If ``formatter`` is ``None``, then the default formatter is used.\n",
      " |      If a callable then that function should take a data value as input and return\n",
      " |      a displayable representation, such as a string. If ``formatter`` is\n",
      " |      given as a string this is assumed to be a valid Python format specification\n",
      " |      and is wrapped to a callable as ``string.format(x)``. If a ``dict`` is given,\n",
      " |      keys should correspond to column names, and values should be string or\n",
      " |      callable, as above.\n",
      " |      \n",
      " |      The default formatter currently expresses floats and complex numbers with the\n",
      " |      pandas display precision unless using the ``precision`` argument here. The\n",
      " |      default formatter does not adjust the representation of missing values unless\n",
      " |      the ``na_rep`` argument is used.\n",
      " |      \n",
      " |      The ``subset`` argument defines which region to apply the formatting function\n",
      " |      to. If the ``formatter`` argument is given in dict form but does not include\n",
      " |      all columns within the subset then these columns will have the default formatter\n",
      " |      applied. Any columns in the formatter dict excluded from the subset will\n",
      " |      be ignored.\n",
      " |      \n",
      " |      When using a ``formatter`` string the dtypes must be compatible, otherwise a\n",
      " |      `ValueError` will be raised.\n",
      " |      \n",
      " |      When instantiating a Styler, default formatting can be applied be setting the\n",
      " |      ``pandas.options``:\n",
      " |      \n",
      " |        - ``styler.format.formatter``: default None.\n",
      " |        - ``styler.format.na_rep``: default None.\n",
      " |        - ``styler.format.precision``: default 6.\n",
      " |        - ``styler.format.decimal``: default \".\".\n",
      " |        - ``styler.format.thousands``: default None.\n",
      " |        - ``styler.format.escape``: default None.\n",
      " |      \n",
      " |      .. warning::\n",
      " |         `Styler.format` is ignored when using the output format `Styler.to_excel`,\n",
      " |         since Excel and Python have inherrently different formatting structures.\n",
      " |         However, it is possible to use the `number-format` pseudo CSS attribute\n",
      " |         to force Excel permissible formatting. See examples.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Using ``na_rep`` and ``precision`` with the default ``formatter``\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[np.nan, 1.0, 'A'], [2.0, np.nan, 3.0]])\n",
      " |      >>> df.style.format(na_rep='MISS', precision=3)  # doctest: +SKIP\n",
      " |              0       1       2\n",
      " |      0    MISS   1.000       A\n",
      " |      1   2.000    MISS   3.000\n",
      " |      \n",
      " |      Using a ``formatter`` specification on consistent column dtypes\n",
      " |      \n",
      " |      >>> df.style.format('{:.2f}', na_rep='MISS', subset=[0,1])  # doctest: +SKIP\n",
      " |              0      1          2\n",
      " |      0    MISS   1.00          A\n",
      " |      1    2.00   MISS   3.000000\n",
      " |      \n",
      " |      Using the default ``formatter`` for unspecified columns\n",
      " |      \n",
      " |      >>> df.style.format({0: '{:.2f}', 1: '£ {:.1f}'}, na_rep='MISS', precision=1)\n",
      " |      ...  # doctest: +SKIP\n",
      " |               0      1     2\n",
      " |      0    MISS   £ 1.0     A\n",
      " |      1    2.00    MISS   3.0\n",
      " |      \n",
      " |      Multiple ``na_rep`` or ``precision`` specifications under the default\n",
      " |      ``formatter``.\n",
      " |      \n",
      " |      >>> df.style.format(na_rep='MISS', precision=1, subset=[0])\n",
      " |      ...     .format(na_rep='PASS', precision=2, subset=[1, 2])  # doctest: +SKIP\n",
      " |              0      1      2\n",
      " |      0    MISS   1.00      A\n",
      " |      1     2.0   PASS   3.00\n",
      " |      \n",
      " |      Using a callable ``formatter`` function.\n",
      " |      \n",
      " |      >>> func = lambda s: 'STRING' if isinstance(s, str) else 'FLOAT'\n",
      " |      >>> df.style.format({0: '{:.1f}', 2: func}, precision=4, na_rep='MISS')\n",
      " |      ...  # doctest: +SKIP\n",
      " |              0        1        2\n",
      " |      0    MISS   1.0000   STRING\n",
      " |      1     2.0     MISS    FLOAT\n",
      " |      \n",
      " |      Using a ``formatter`` with HTML ``escape`` and ``na_rep``.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([['<div></div>', '\"A&B\"', None]])\n",
      " |      >>> s = df.style.format(\n",
      " |      ...     '<a href=\"a.com/{0}\">{0}</a>', escape=\"html\", na_rep=\"NA\"\n",
      " |      ...     )\n",
      " |      >>> s.to_html()  # doctest: +SKIP\n",
      " |      ...\n",
      " |      <td .. ><a href=\"a.com/&lt;div&gt;&lt;/div&gt;\">&lt;div&gt;&lt;/div&gt;</a></td>\n",
      " |      <td .. ><a href=\"a.com/&#34;A&amp;B&#34;\">&#34;A&amp;B&#34;</a></td>\n",
      " |      <td .. >NA</td>\n",
      " |      ...\n",
      " |      \n",
      " |      Using a ``formatter`` with LaTeX ``escape``.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[\"123\"], [\"~ ^\"], [\"$%#\"]])\n",
      " |      >>> df.style.format(\"\\\\textbf{{{}}}\", escape=\"latex\").to_latex()\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \\begin{tabular}{ll}\n",
      " |      {} & {0} \\\\\n",
      " |      0 & \\textbf{123} \\\\\n",
      " |      1 & \\textbf{\\textasciitilde \\space \\textasciicircum } \\\\\n",
      " |      2 & \\textbf{\\$\\%\\#} \\\\\n",
      " |      \\end{tabular}\n",
      " |      \n",
      " |      Pandas defines a `number-format` pseudo CSS attribute instead of the `.format`\n",
      " |      method to create `to_excel` permissible formatting. Note that semi-colons are\n",
      " |      CSS protected characters but used as separators in Excel's format string.\n",
      " |      Replace semi-colons with the section separator character (ASCII-245) when\n",
      " |      defining the formatting here.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame({\"A\": [1, 0, -1]})\n",
      " |      >>> pseudo_css = \"number-format: 0§[Red](0)§-§@;\"\n",
      " |      >>> df.style.applymap(lambda v: css).to_excel(\"formatted_file.xlsx\")\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \n",
      " |      .. figure:: ../../_static/style/format_excel_css.png\n",
      " |  \n",
      " |  format_index(self, formatter: 'ExtFormatter | None' = None, axis: 'int | str' = 0, level: 'Level | list[Level] | None' = None, na_rep: 'str | None' = None, precision: 'int | None' = None, decimal: 'str' = '.', thousands: 'str | None' = None, escape: 'str | None' = None, hyperlinks: 'str | None' = None) -> 'StylerRenderer'\n",
      " |      Format the text display value of index labels or column headers.\n",
      " |      \n",
      " |      .. versionadded:: 1.4.0\n",
      " |      \n",
      " |      Parameters\n",
      " |      ----------\n",
      " |      formatter : str, callable, dict or None\n",
      " |          Object to define how values are displayed. See notes.\n",
      " |      axis : {0, \"index\", 1, \"columns\"}\n",
      " |          Whether to apply the formatter to the index or column headers.\n",
      " |      level : int, str, list\n",
      " |          The level(s) over which to apply the generic formatter.\n",
      " |      na_rep : str, optional\n",
      " |          Representation for missing values.\n",
      " |          If ``na_rep`` is None, no special formatting is applied.\n",
      " |      precision : int, optional\n",
      " |          Floating point precision to use for display purposes, if not determined by\n",
      " |          the specified ``formatter``.\n",
      " |      decimal : str, default \".\"\n",
      " |          Character used as decimal separator for floats, complex and integers.\n",
      " |      thousands : str, optional, default None\n",
      " |          Character used as thousands separator for floats, complex and integers.\n",
      " |      escape : str, optional\n",
      " |          Use 'html' to replace the characters ``&``, ``<``, ``>``, ``'``, and ``\"``\n",
      " |          in cell display string with HTML-safe sequences.\n",
      " |          Use 'latex' to replace the characters ``&``, ``%``, ``$``, ``#``, ``_``,\n",
      " |          ``{``, ``}``, ``~``, ``^``, and ``\\`` in the cell display string with\n",
      " |          LaTeX-safe sequences.\n",
      " |          Escaping is done before ``formatter``.\n",
      " |      hyperlinks : {\"html\", \"latex\"}, optional\n",
      " |          Convert string patterns containing https://, http://, ftp:// or www. to\n",
      " |          HTML <a> tags as clickable URL hyperlinks if \"html\", or LaTeX \\href\n",
      " |          commands if \"latex\".\n",
      " |      \n",
      " |      Returns\n",
      " |      -------\n",
      " |      self : Styler\n",
      " |      \n",
      " |      See Also\n",
      " |      --------\n",
      " |      Styler.format: Format the text display value of data cells.\n",
      " |      \n",
      " |      Notes\n",
      " |      -----\n",
      " |      This method assigns a formatting function, ``formatter``, to each level label\n",
      " |      in the DataFrame's index or column headers. If ``formatter`` is ``None``,\n",
      " |      then the default formatter is used.\n",
      " |      If a callable then that function should take a label value as input and return\n",
      " |      a displayable representation, such as a string. If ``formatter`` is\n",
      " |      given as a string this is assumed to be a valid Python format specification\n",
      " |      and is wrapped to a callable as ``string.format(x)``. If a ``dict`` is given,\n",
      " |      keys should correspond to MultiIndex level numbers or names, and values should\n",
      " |      be string or callable, as above.\n",
      " |      \n",
      " |      The default formatter currently expresses floats and complex numbers with the\n",
      " |      pandas display precision unless using the ``precision`` argument here. The\n",
      " |      default formatter does not adjust the representation of missing values unless\n",
      " |      the ``na_rep`` argument is used.\n",
      " |      \n",
      " |      The ``level`` argument defines which levels of a MultiIndex to apply the\n",
      " |      method to. If the ``formatter`` argument is given in dict form but does\n",
      " |      not include all levels within the level argument then these unspecified levels\n",
      " |      will have the default formatter applied. Any levels in the formatter dict\n",
      " |      specifically excluded from the level argument will be ignored.\n",
      " |      \n",
      " |      When using a ``formatter`` string the dtypes must be compatible, otherwise a\n",
      " |      `ValueError` will be raised.\n",
      " |      \n",
      " |      .. warning::\n",
      " |         `Styler.format_index` is ignored when using the output format\n",
      " |         `Styler.to_excel`, since Excel and Python have inherrently different\n",
      " |         formatting structures.\n",
      " |         However, it is possible to use the `number-format` pseudo CSS attribute\n",
      " |         to force Excel permissible formatting. See documentation for `Styler.format`.\n",
      " |      \n",
      " |      Examples\n",
      " |      --------\n",
      " |      Using ``na_rep`` and ``precision`` with the default ``formatter``\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2, 3]], columns=[2.0, np.nan, 4.0])\n",
      " |      >>> df.style.format_index(axis=1, na_rep='MISS', precision=3)  # doctest: +SKIP\n",
      " |          2.000    MISS   4.000\n",
      " |      0       1       2       3\n",
      " |      \n",
      " |      Using a ``formatter`` specification on consistent dtypes in a level\n",
      " |      \n",
      " |      >>> df.style.format_index('{:.2f}', axis=1, na_rep='MISS')  # doctest: +SKIP\n",
      " |           2.00   MISS    4.00\n",
      " |      0       1      2       3\n",
      " |      \n",
      " |      Using the default ``formatter`` for unspecified levels\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2, 3]],\n",
      " |      ...     columns=pd.MultiIndex.from_arrays([[\"a\", \"a\", \"b\"],[2, np.nan, 4]]))\n",
      " |      >>> df.style.format_index({0: lambda v: upper(v)}, axis=1, precision=1)\n",
      " |      ...  # doctest: +SKIP\n",
      " |                     A       B\n",
      " |            2.0    nan     4.0\n",
      " |      0       1      2       3\n",
      " |      \n",
      " |      Using a callable ``formatter`` function.\n",
      " |      \n",
      " |      >>> func = lambda s: 'STRING' if isinstance(s, str) else 'FLOAT'\n",
      " |      >>> df.style.format_index(func, axis=1, na_rep='MISS')\n",
      " |      ...  # doctest: +SKIP\n",
      " |                STRING  STRING\n",
      " |          FLOAT   MISS   FLOAT\n",
      " |      0       1      2       3\n",
      " |      \n",
      " |      Using a ``formatter`` with HTML ``escape`` and ``na_rep``.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2, 3]], columns=['\"A\"', 'A&B', None])\n",
      " |      >>> s = df.style.format_index('$ {0}', axis=1, escape=\"html\", na_rep=\"NA\")\n",
      " |      ...  # doctest: +SKIP\n",
      " |      <th .. >$ &#34;A&#34;</th>\n",
      " |      <th .. >$ A&amp;B</th>\n",
      " |      <th .. >NA</td>\n",
      " |      ...\n",
      " |      \n",
      " |      Using a ``formatter`` with LaTeX ``escape``.\n",
      " |      \n",
      " |      >>> df = pd.DataFrame([[1, 2, 3]], columns=[\"123\", \"~\", \"$%#\"])\n",
      " |      >>> df.style.format_index(\"\\\\textbf{{{}}}\", escape=\"latex\", axis=1).to_latex()\n",
      " |      ...  # doctest: +SKIP\n",
      " |      \\begin{tabular}{lrrr}\n",
      " |      {} & {\\textbf{123}} & {\\textbf{\\textasciitilde }} & {\\textbf{\\$\\%\\#}} \\\\\n",
      " |      0 & 1 & 2 & 3 \\\\\n",
      " |      \\end{tabular}\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from pandas.io.formats.style_render.StylerRenderer:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from pandas.io.formats.style_render.StylerRenderer:\n",
      " |  \n",
      " |  env = <jinja2.environment.Environment object>\n",
      " |      The core component of Jinja is the `Environment`.  It contains\n",
      " |          important shared variables like configuration, filters, tests,\n",
      " |          globals and others.  Instances of this class may be modified if\n",
      " |          they are not shared and if no template was loaded so far.\n",
      " |          Modifications on environments after the first template was loaded\n",
      " |          will lead to surprising effects and undefined behavior.\n",
      " |      \n",
      " |          Here are the possible initialization parameters:\n",
      " |      \n",
      " |              `block_start_string`\n",
      " |                  The string marking the beginning of a block.  Defaults to ``'{%'``.\n",
      " |      \n",
      " |              `block_end_string`\n",
      " |                  The string marking the end of a block.  Defaults to ``'%}'``.\n",
      " |      \n",
      " |              `variable_start_string`\n",
      " |                  The string marking the beginning of a print statement.\n",
      " |                  Defaults to ``'{{'``.\n",
      " |      \n",
      " |              `variable_end_string`\n",
      " |                  The string marking the end of a print statement.  Defaults to\n",
      " |                  ``'}}'``.\n",
      " |      \n",
      " |              `comment_start_string`\n",
      " |                  The string marking the beginning of a comment.  Defaults to ``'{#'``.\n",
      " |      \n",
      " |              `comment_end_string`\n",
      " |                  The string marking the end of a comment.  Defaults to ``'#}'``.\n",
      " |      \n",
      " |              `line_statement_prefix`\n",
      " |                  If given and a string, this will be used as prefix for line based\n",
      " |                  statements.  See also :ref:`line-statements`.\n",
      " |      \n",
      " |              `line_comment_prefix`\n",
      " |                  If given and a string, this will be used as prefix for line based\n",
      " |                  comments.  See also :ref:`line-statements`.\n",
      " |      \n",
      " |                  .. versionadded:: 2.2\n",
      " |      \n",
      " |              `trim_blocks`\n",
      " |                  If this is set to ``True`` the first newline after a block is\n",
      " |                  removed (block, not variable tag!).  Defaults to `False`.\n",
      " |      \n",
      " |              `lstrip_blocks`\n",
      " |                  If this is set to ``True`` leading spaces and tabs are stripped\n",
      " |                  from the start of a line to a block.  Defaults to `False`.\n",
      " |      \n",
      " |              `newline_sequence`\n",
      " |                  The sequence that starts a newline.  Must be one of ``'\\r'``,\n",
      " |                  ``'\\n'`` or ``'\\r\\n'``.  The default is ``'\\n'`` which is a\n",
      " |                  useful default for Linux and OS X systems as well as web\n",
      " |                  applications.\n",
      " |      \n",
      " |              `keep_trailing_newline`\n",
      " |                  Preserve the trailing newline when rendering templates.\n",
      " |                  The default is ``False``, which causes a single newline,\n",
      " |                  if present, to be stripped from the end of the template.\n",
      " |      \n",
      " |                  .. versionadded:: 2.7\n",
      " |      \n",
      " |              `extensions`\n",
      " |                  List of Jinja extensions to use.  This can either be import paths\n",
      " |                  as strings or extension classes.  For more information have a\n",
      " |                  look at :ref:`the extensions documentation <jinja-extensions>`.\n",
      " |      \n",
      " |              `optimized`\n",
      " |                  should the optimizer be enabled?  Default is ``True``.\n",
      " |      \n",
      " |              `undefined`\n",
      " |                  :class:`Undefined` or a subclass of it that is used to represent\n",
      " |                  undefined values in the template.\n",
      " |      \n",
      " |              `finalize`\n",
      " |                  A callable that can be used to process the result of a variable\n",
      " |                  expression before it is output.  For example one can convert\n",
      " |                  ``None`` implicitly into an empty string here.\n",
      " |      \n",
      " |              `autoescape`\n",
      " |                  If set to ``True`` the XML/HTML autoescaping feature is enabled by\n",
      " |                  default.  For more details about autoescaping see\n",
      " |                  :class:`~markupsafe.Markup`.  As of Jinja 2.4 this can also\n",
      " |                  be a callable that is passed the template name and has to\n",
      " |                  return ``True`` or ``False`` depending on autoescape should be\n",
      " |                  enabled by default.\n",
      " |      \n",
      " |                  .. versionchanged:: 2.4\n",
      " |                     `autoescape` can now be a function\n",
      " |      \n",
      " |              `loader`\n",
      " |                  The template loader for this environment.\n",
      " |      \n",
      " |              `cache_size`\n",
      " |                  The size of the cache.  Per default this is ``400`` which means\n",
      " |                  that if more than 400 templates are loaded the loader will clean\n",
      " |                  out the least recently used template.  If the cache size is set to\n",
      " |                  ``0`` templates are recompiled all the time, if the cache size is\n",
      " |                  ``-1`` the cache will not be cleaned.\n",
      " |      \n",
      " |                  .. versionchanged:: 2.8\n",
      " |                     The cache size was increased to 400 from a low 50.\n",
      " |      \n",
      " |              `auto_reload`\n",
      " |                  Some loaders load templates from locations where the template\n",
      " |                  sources may change (ie: file system or database).  If\n",
      " |                  ``auto_reload`` is set to ``True`` (default) every time a template is\n",
      " |                  requested the loader checks if the source changed and if yes, it\n",
      " |                  will reload the template.  For higher performance it's possible to\n",
      " |                  disable that.\n",
      " |      \n",
      " |              `bytecode_cache`\n",
      " |                  If set to a bytecode cache object, this object will provide a\n",
      " |                  cache for the internal Jinja bytecode so that templates don't\n",
      " |                  have to be parsed if they were not changed.\n",
      " |      \n",
      " |                  See :ref:`bytecode-cache` for more information.\n",
      " |      \n",
      " |              `enable_async`\n",
      " |                  If set to true this enables async template execution which allows\n",
      " |                  you to take advantage of newer Python features.  This requires\n",
      " |                  Python 3.6 or later.\n",
      " |  \n",
      " |  \n",
      " |  loader = <jinja2.loaders.PackageLoader object>\n",
      " |      Load templates from python eggs or packages.  It is constructed with\n",
      " |          the name of the python package and the path to the templates in that\n",
      " |          package::\n",
      " |      \n",
      " |              loader = PackageLoader('mypackage', 'views')\n",
      " |      \n",
      " |          If the package path is not given, ``'templates'`` is assumed.\n",
      " |      \n",
      " |          Per default the template encoding is ``'utf-8'`` which can be changed\n",
      " |          by setting the `encoding` parameter to something else.  Due to the nature\n",
      " |          of eggs it's only possible to reload templates if the package was loaded\n",
      " |          from the file system and not a zip file.\n",
      " |  \n",
      " |  \n",
      " |  template_html = <Template 'html.tpl'>\n",
      " |      The central template object.  This class represents a compiled template\n",
      " |          and is used to evaluate it.\n",
      " |      \n",
      " |          Normally the template object is generated from an :class:`Environment` but\n",
      " |          it also has a constructor that makes it possible to create a template\n",
      " |          instance directly using the constructor.  It takes the same arguments as\n",
      " |          the environment constructor but it's not possible to specify a loader.\n",
      " |      \n",
      " |          Every template object has a few methods and members that are guaranteed\n",
      " |          to exist.  However it's important that a template object should be\n",
      " |          considered immutable.  Modifications on the object are not supported.\n",
      " |      \n",
      " |          Template objects created from the constructor rather than an environment\n",
      " |          do have an `environment` attribute that points to a temporary environment\n",
      " |          that is probably shared with other templates created with the constructor\n",
      " |          and compatible settings.\n",
      " |      \n",
      " |          >>> template = Template('Hello {{ name }}!')\n",
      " |          >>> template.render(name='John Doe') == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> stream = template.stream(name='John Doe')\n",
      " |          >>> next(stream) == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> next(stream)\n",
      " |          Traceback (most recent call last):\n",
      " |              ...\n",
      " |          StopIteration\n",
      " |  \n",
      " |  \n",
      " |  template_html_style = <Template 'html_style.tpl'>\n",
      " |      The central template object.  This class represents a compiled template\n",
      " |          and is used to evaluate it.\n",
      " |      \n",
      " |          Normally the template object is generated from an :class:`Environment` but\n",
      " |          it also has a constructor that makes it possible to create a template\n",
      " |          instance directly using the constructor.  It takes the same arguments as\n",
      " |          the environment constructor but it's not possible to specify a loader.\n",
      " |      \n",
      " |          Every template object has a few methods and members that are guaranteed\n",
      " |          to exist.  However it's important that a template object should be\n",
      " |          considered immutable.  Modifications on the object are not supported.\n",
      " |      \n",
      " |          Template objects created from the constructor rather than an environment\n",
      " |          do have an `environment` attribute that points to a temporary environment\n",
      " |          that is probably shared with other templates created with the constructor\n",
      " |          and compatible settings.\n",
      " |      \n",
      " |          >>> template = Template('Hello {{ name }}!')\n",
      " |          >>> template.render(name='John Doe') == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> stream = template.stream(name='John Doe')\n",
      " |          >>> next(stream) == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> next(stream)\n",
      " |          Traceback (most recent call last):\n",
      " |              ...\n",
      " |          StopIteration\n",
      " |  \n",
      " |  \n",
      " |  template_html_table = <Template 'html_table.tpl'>\n",
      " |      The central template object.  This class represents a compiled template\n",
      " |          and is used to evaluate it.\n",
      " |      \n",
      " |          Normally the template object is generated from an :class:`Environment` but\n",
      " |          it also has a constructor that makes it possible to create a template\n",
      " |          instance directly using the constructor.  It takes the same arguments as\n",
      " |          the environment constructor but it's not possible to specify a loader.\n",
      " |      \n",
      " |          Every template object has a few methods and members that are guaranteed\n",
      " |          to exist.  However it's important that a template object should be\n",
      " |          considered immutable.  Modifications on the object are not supported.\n",
      " |      \n",
      " |          Template objects created from the constructor rather than an environment\n",
      " |          do have an `environment` attribute that points to a temporary environment\n",
      " |          that is probably shared with other templates created with the constructor\n",
      " |          and compatible settings.\n",
      " |      \n",
      " |          >>> template = Template('Hello {{ name }}!')\n",
      " |          >>> template.render(name='John Doe') == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> stream = template.stream(name='John Doe')\n",
      " |          >>> next(stream) == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> next(stream)\n",
      " |          Traceback (most recent call last):\n",
      " |              ...\n",
      " |          StopIteration\n",
      " |  \n",
      " |  \n",
      " |  template_latex = <Template 'latex.tpl'>\n",
      " |      The central template object.  This class represents a compiled template\n",
      " |          and is used to evaluate it.\n",
      " |      \n",
      " |          Normally the template object is generated from an :class:`Environment` but\n",
      " |          it also has a constructor that makes it possible to create a template\n",
      " |          instance directly using the constructor.  It takes the same arguments as\n",
      " |          the environment constructor but it's not possible to specify a loader.\n",
      " |      \n",
      " |          Every template object has a few methods and members that are guaranteed\n",
      " |          to exist.  However it's important that a template object should be\n",
      " |          considered immutable.  Modifications on the object are not supported.\n",
      " |      \n",
      " |          Template objects created from the constructor rather than an environment\n",
      " |          do have an `environment` attribute that points to a temporary environment\n",
      " |          that is probably shared with other templates created with the constructor\n",
      " |          and compatible settings.\n",
      " |      \n",
      " |          >>> template = Template('Hello {{ name }}!')\n",
      " |          >>> template.render(name='John Doe') == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> stream = template.stream(name='John Doe')\n",
      " |          >>> next(stream) == u'Hello John Doe!'\n",
      " |          True\n",
      " |          >>> next(stream)\n",
      " |          Traceback (most recent call last):\n",
      " |              ...\n",
      " |          StopIteration\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(df_new.style)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a39c8a9",
   "metadata": {},
   "source": [
    "### 在streamlit 中实现上面代码并实现模型参数的调节功能-classwork3\n",
    "\n",
    "https://docs.streamlit.io/library/api-reference/control-flow/st.form"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86cf0188",
   "metadata": {},
   "outputs": [],
   "source": [
    "import streamlit as st\n",
    "\n",
    "with st.form(\"my_form\"):\n",
    "   st.write(\"Inside the form\")\n",
    "   slider_val = st.slider(\"Form slider\")\n",
    "   checkbox_val = st.checkbox(\"Form checkbox\")\n",
    "\n",
    "   # Every form must have a submit button.\n",
    "   submitted = st.form_submit_button(\"Submit\")\n",
    "   if submitted:\n",
    "       st.write(\"slider\", slider_val, \"checkbox\", checkbox_val)\n",
    "\n",
    "st.write(\"Outside the form\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c146a5f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5409b4c3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "bd698f25",
   "metadata": {},
   "source": [
    "### 构建分页应用-classwork4\n",
    "\n",
    "* 第一页分析数据训练模型\n",
    "\n",
    "* 第二页使用模型，通过session state实现分页共享变量\n",
    "\n",
    "https://docs.streamlit.io/library/get-started/main-concepts\n",
    "\n",
    "https://docs.streamlit.io/library/api-reference/session-state"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "340e3009",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Initialization\n",
    "if 'key' not in st.session_state:\n",
    "    st.session_state['key'] = 'value'\n",
    "\n",
    "# Session State also supports attribute based syntax\n",
    "if 'key' not in st.session_state:\n",
    "    st.session_state.key = 'value'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4e97cea",
   "metadata": {},
   "source": [
    "### 实现模型与数据的本地导入与保存-classwork5\n",
    "\n",
    "https://docs.streamlit.io/library/api-reference/widgets/st.download_button\n",
    "\n",
    "* 实现新数据通过本地文件导入\n",
    "\n",
    "* 实现按钮控制模型导出到本地\n",
    "\n",
    "* 实现模型通过本地文件导入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7694b09a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import streamlit as st\n",
    "import pandas as pd\n",
    "from io import StringIO\n",
    "\n",
    "uploaded_file = st.file_uploader(\"Choose a file\")\n",
    "if uploaded_file is not None:\n",
    "    # To read file as bytes:\n",
    "    bytes_data = uploaded_file.getvalue()\n",
    "    st.write(bytes_data)\n",
    "\n",
    "    # To convert to a string based IO:\n",
    "    stringio = StringIO(uploaded_file.getvalue().decode(\"utf-8\"))\n",
    "    st.write(stringio)\n",
    "\n",
    "    # To read file as string:\n",
    "    string_data = stringio.read()\n",
    "    st.write(string_data)\n",
    "\n",
    "    # Can be used wherever a \"file-like\" object is accepted:\n",
    "    dataframe = pd.read_csv(uploaded_file)\n",
    "    st.write(dataframe)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "56c58b9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0e7ffed9",
   "metadata": {},
   "outputs": [],
   "source": [
    "pkl_filename = \"F:\\\\pickle_model.pkl\"\n",
    "with open(pkl_filename, 'wb') as file:\n",
    "    pickle.dump(model, file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "92ee6be4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load from file\n",
    "with open(pkl_filename, 'rb') as file:\n",
    "    pickle_model = pickle.load(file)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fc9d44d",
   "metadata": {},
   "source": [
    "### 在模型训练页加入透视表分析,并通过表单控制表的维度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "58e1cb05",
   "metadata": {},
   "outputs": [],
   "source": [
    "#help(df.pivot_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "49dc94cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Name', 'Age', 'Gender', 'Area', 'Email', 'Mobile', 'Logins 4 weeks',\n",
       "       'Logins 6 months', 'Sales 4 weeks', 'Sales 6 months', 'Sales total',\n",
       "       'Response'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "39191e57",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Area</th>\n",
       "      <th>Email</th>\n",
       "      <th>Mobile</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "      <th>Response</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>COX</td>\n",
       "      <td>64</td>\n",
       "      <td>female</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>never</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>FARLEY</td>\n",
       "      <td>49</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>premium</td>\n",
       "      <td>never</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HYDE</td>\n",
       "      <td>63</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>never</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>SANTIAGO</td>\n",
       "      <td>75</td>\n",
       "      <td>male</td>\n",
       "      <td>urban</td>\n",
       "      <td>premium</td>\n",
       "      <td>yes</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>COPELAND</td>\n",
       "      <td>37</td>\n",
       "      <td>female</td>\n",
       "      <td>urban</td>\n",
       "      <td>free</td>\n",
       "      <td>yes</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>62</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Name  Age  Gender   Area    Email Mobile  Logins 4 weeks  \\\n",
       "0       COX   64  female  urban     free  never               1   \n",
       "1    FARLEY   49    male  urban  premium  never               0   \n",
       "2      HYDE   63    male  urban     free  never               0   \n",
       "3  SANTIAGO   75    male  urban  premium    yes               0   \n",
       "4  COPELAND   37  female  urban     free    yes               0   \n",
       "\n",
       "   Logins 6 months  Sales 4 weeks  Sales 6 months  Sales total Response  \n",
       "0                1              0               0            0       no  \n",
       "1                4              0               0            0      yes  \n",
       "2                0              0               0            0       no  \n",
       "3                0              0               0            0      yes  \n",
       "4                0              0               0           62       no  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c954d2a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "pivot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "11863b2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"6\" halign=\"left\">mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Response</th>\n",
       "      <th>Gender</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">no</th>\n",
       "      <th>female</th>\n",
       "      <td>46.807190</td>\n",
       "      <td>0.375817</td>\n",
       "      <td>1.928105</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.738562</td>\n",
       "      <td>14.539216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>male</th>\n",
       "      <td>47.232000</td>\n",
       "      <td>0.196000</td>\n",
       "      <td>1.360000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.140000</td>\n",
       "      <td>16.384000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">yes</th>\n",
       "      <th>female</th>\n",
       "      <td>45.901316</td>\n",
       "      <td>4.296053</td>\n",
       "      <td>8.098684</td>\n",
       "      <td>10.677632</td>\n",
       "      <td>35.276316</td>\n",
       "      <td>58.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>male</th>\n",
       "      <td>46.030822</td>\n",
       "      <td>2.732877</td>\n",
       "      <td>4.852740</td>\n",
       "      <td>7.421233</td>\n",
       "      <td>25.801370</td>\n",
       "      <td>39.654110</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      mean                                               \\\n",
       "                       Age Logins 4 weeks Logins 6 months Sales 4 weeks   \n",
       "Response Gender                                                           \n",
       "no       female  46.807190       0.375817        1.928105      0.000000   \n",
       "         male    47.232000       0.196000        1.360000      0.000000   \n",
       "yes      female  45.901316       4.296053        8.098684     10.677632   \n",
       "         male    46.030822       2.732877        4.852740      7.421233   \n",
       "\n",
       "                                            \n",
       "                Sales 6 months Sales total  \n",
       "Response Gender                             \n",
       "no       female       3.738562   14.539216  \n",
       "         male         2.140000   16.384000  \n",
       "yes      female      35.276316   58.250000  \n",
       "         male        25.801370   39.654110  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.pivot_table(index=[\"Response\",\"Gender\"],aggfunc=[np.mean])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "0cc9ed03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Response</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>no</th>\n",
       "      <td>46.998201</td>\n",
       "      <td>0.294964</td>\n",
       "      <td>1.672662</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.019784</td>\n",
       "      <td>15.368705</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>yes</th>\n",
       "      <td>45.986486</td>\n",
       "      <td>3.268018</td>\n",
       "      <td>5.963964</td>\n",
       "      <td>8.536036</td>\n",
       "      <td>29.045045</td>\n",
       "      <td>46.020270</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                Age  Logins 4 weeks  Logins 6 months  Sales 4 weeks  \\\n",
       "Response                                                              \n",
       "no        46.998201        0.294964         1.672662       0.000000   \n",
       "yes       45.986486        3.268018         5.963964       8.536036   \n",
       "\n",
       "          Sales 6 months  Sales total  \n",
       "Response                               \n",
       "no              3.019784    15.368705  \n",
       "yes            29.045045    46.020270  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.pivot_table(index=\"Response\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5ce61457",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"6\" halign=\"left\">mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Logins 4 weeks</th>\n",
       "      <th>Logins 6 months</th>\n",
       "      <th>Sales 4 weeks</th>\n",
       "      <th>Sales 6 months</th>\n",
       "      <th>Sales total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Response</th>\n",
       "      <th>Gender</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">no</th>\n",
       "      <th>female</th>\n",
       "      <td>46.807190</td>\n",
       "      <td>0.375817</td>\n",
       "      <td>1.928105</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.738562</td>\n",
       "      <td>14.539216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>male</th>\n",
       "      <td>47.232000</td>\n",
       "      <td>0.196000</td>\n",
       "      <td>1.360000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.140000</td>\n",
       "      <td>16.384000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">yes</th>\n",
       "      <th>female</th>\n",
       "      <td>45.901316</td>\n",
       "      <td>4.296053</td>\n",
       "      <td>8.098684</td>\n",
       "      <td>10.677632</td>\n",
       "      <td>35.276316</td>\n",
       "      <td>58.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>male</th>\n",
       "      <td>46.030822</td>\n",
       "      <td>2.732877</td>\n",
       "      <td>4.852740</td>\n",
       "      <td>7.421233</td>\n",
       "      <td>25.801370</td>\n",
       "      <td>39.654110</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      mean                                               \\\n",
       "                       Age Logins 4 weeks Logins 6 months Sales 4 weeks   \n",
       "Response Gender                                                           \n",
       "no       female  46.807190       0.375817        1.928105      0.000000   \n",
       "         male    47.232000       0.196000        1.360000      0.000000   \n",
       "yes      female  45.901316       4.296053        8.098684     10.677632   \n",
       "         male    46.030822       2.732877        4.852740      7.421233   \n",
       "\n",
       "                                            \n",
       "                Sales 6 months Sales total  \n",
       "Response Gender                             \n",
       "no       female       3.738562   14.539216  \n",
       "         male         2.140000   16.384000  \n",
       "yes      female      35.276316   58.250000  \n",
       "         male        25.801370   39.654110  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1=df.pivot_table(index=[\"Response\",\"Gender\"],aggfunc=[np.mean])\n",
    "z1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "7b8c5e87",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('no', 'female'), ('no', 'male'), ('yes', 'female'), ('yes', 'male')]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1.index.tolist()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19ced843",
   "metadata": {},
   "source": [
    "### 对透视表分析进行可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "7b23b6ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mean_Age\n",
      "mean_Logins 4 weeks\n",
      "mean_Logins 6 months\n",
      "mean_Sales 4 weeks\n",
      "mean_Sales 6 months\n",
      "mean_Sales total\n"
     ]
    }
   ],
   "source": [
    "for i in z1.columns:\n",
    "    print(\"_\".join(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "5edbbb26",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mean_Age',\n",
       " 'mean_Logins 4 weeks',\n",
       " 'mean_Logins 6 months',\n",
       " 'mean_Sales 4 weeks',\n",
       " 'mean_Sales 6 months',\n",
       " 'mean_Sales total']"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[\"_\".join(i) for i in z1.columns]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b274f512",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isinstance(z1.columns[0], tuple)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "438d8364",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('mean', 'Age')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1.columns[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "8a89cf8d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isinstance(z1.index[0], tuple)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "ee4be613",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(z1.columns[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3a1fd145",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "no-female\n",
      "no-male\n",
      "yes-female\n",
      "yes-male\n"
     ]
    }
   ],
   "source": [
    "for i in z1.index:\n",
    "    print(i[0]+\"-\"+i[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "ef6c7d70",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "print(type(z1.index[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "daed9cd6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MultiIndex([('mean',             'Age'),\n",
       "            ('mean',  'Logins 4 weeks'),\n",
       "            ('mean', 'Logins 6 months'),\n",
       "            ('mean',   'Sales 4 weeks'),\n",
       "            ('mean',  'Sales 6 months'),\n",
       "            ('mean',     'Sales total')],\n",
       "           )"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ae036211",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mean-Age',\n",
       " 'mean-Logins 4 weeks',\n",
       " 'mean-Logins 6 months',\n",
       " 'mean-Sales 4 weeks',\n",
       " 'mean-Sales 6 months',\n",
       " 'mean-Sales total']"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[ \"-\".join(i) for i in z1.columns]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "3884c47c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1.22.4'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.__version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "36a9631e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MultiIndex([('mean',             'Age'),\n",
       "            ('mean',  'Logins 4 weeks'),\n",
       "            ('mean', 'Logins 6 months'),\n",
       "            ('mean',   'Sales 4 weeks'),\n",
       "            ('mean',  'Sales 6 months'),\n",
       "            ('mean',     'Sales total')],\n",
       "           )"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "fab46e33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[46.80718954248366, 47.232, 45.901315789473685, 46.03082191780822]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1.iloc[:,0].tolist()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1220fe2a",
   "metadata": {},
   "source": [
    "## 用户流失预警系统的搭建\n",
    "\n",
    "* 流失用户的定义\n",
    "\n",
    "* 样本不平衡问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "3bf6f008",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_csv(r\"F:\\notebooks1\\streamlit\\data\\aaa.csv\",parse_dates=[\"CustomerSince\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "3f1a0356",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Technology</th>\n",
       "      <th>Age</th>\n",
       "      <th>CustomerSince</th>\n",
       "      <th>SupportCallsLastYear</th>\n",
       "      <th>AverageBill</th>\n",
       "      <th>ChurnIndicator</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4G</td>\n",
       "      <td>1</td>\n",
       "      <td>2013-06-06 22:27:16</td>\n",
       "      <td>1</td>\n",
       "      <td>71</td>\n",
       "      <td>0.013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>phone</td>\n",
       "      <td>46</td>\n",
       "      <td>2011-10-05 22:27:16</td>\n",
       "      <td>0</td>\n",
       "      <td>88</td>\n",
       "      <td>0.006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4G</td>\n",
       "      <td>47</td>\n",
       "      <td>2012-07-24 22:27:16</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>0.016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>phone</td>\n",
       "      <td>43</td>\n",
       "      <td>2010-08-31 22:27:16</td>\n",
       "      <td>1</td>\n",
       "      <td>64</td>\n",
       "      <td>0.021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>fiber</td>\n",
       "      <td>37</td>\n",
       "      <td>2011-07-24 22:27:16</td>\n",
       "      <td>2</td>\n",
       "      <td>105</td>\n",
       "      <td>0.032</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Technology  Age       CustomerSince  SupportCallsLastYear  AverageBill  \\\n",
       "0         4G    1 2013-06-06 22:27:16                     1           71   \n",
       "1      phone   46 2011-10-05 22:27:16                     0           88   \n",
       "2         4G   47 2012-07-24 22:27:16                     1           80   \n",
       "3      phone   43 2010-08-31 22:27:16                     1           64   \n",
       "4      fiber   37 2011-07-24 22:27:16                     2          105   \n",
       "\n",
       "   ChurnIndicator  \n",
       "0           0.013  \n",
       "1           0.006  \n",
       "2           0.016  \n",
       "3           0.021  \n",
       "4           0.032  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "6a7715ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "def com_bi(x):\n",
    "    if x>0.4:\n",
    "        return 1\n",
    "    else:\n",
    "        return 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "f847dcaf",
   "metadata": {},
   "outputs": [],
   "source": [
    "df[\"ChurnIndicator\"]=df[\"ChurnIndicator\"].map(com_bi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "377dc2ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.get_dummies(df,columns=[\"Technology\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "2c18f8c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "#df[df[\"ChurnIndicator\"]==1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "676e18ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1079"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(df[\"CustomerSince\"]-df[\"CustomerSince\"].min())[0].days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "bbd236df",
   "metadata": {},
   "outputs": [],
   "source": [
    "min_time=df[\"CustomerSince\"].min()\n",
    "def to_days(x):\n",
    "    return (x-min_time).days\n",
    "df[\"CustomerSince\"]=df[\"CustomerSince\"].map(to_days)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "430f0868",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>CustomerSince</th>\n",
       "      <th>SupportCallsLastYear</th>\n",
       "      <th>AverageBill</th>\n",
       "      <th>ChurnIndicator</th>\n",
       "      <th>Technology_4G</th>\n",
       "      <th>Technology_fiber</th>\n",
       "      <th>Technology_landline</th>\n",
       "      <th>Technology_phone</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1079</td>\n",
       "      <td>1</td>\n",
       "      <td>71</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>46</td>\n",
       "      <td>469</td>\n",
       "      <td>0</td>\n",
       "      <td>88</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>47</td>\n",
       "      <td>762</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>43</td>\n",
       "      <td>69</td>\n",
       "      <td>1</td>\n",
       "      <td>64</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>37</td>\n",
       "      <td>396</td>\n",
       "      <td>2</td>\n",
       "      <td>105</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9985</th>\n",
       "      <td>39</td>\n",
       "      <td>226</td>\n",
       "      <td>5</td>\n",
       "      <td>76</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9986</th>\n",
       "      <td>55</td>\n",
       "      <td>424</td>\n",
       "      <td>1</td>\n",
       "      <td>86</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9987</th>\n",
       "      <td>37</td>\n",
       "      <td>623</td>\n",
       "      <td>2</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9988</th>\n",
       "      <td>22</td>\n",
       "      <td>449</td>\n",
       "      <td>0</td>\n",
       "      <td>53</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9989</th>\n",
       "      <td>79</td>\n",
       "      <td>229</td>\n",
       "      <td>4</td>\n",
       "      <td>86</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9990 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Age  CustomerSince  SupportCallsLastYear  AverageBill  ChurnIndicator  \\\n",
       "0       1           1079                     1           71               0   \n",
       "1      46            469                     0           88               0   \n",
       "2      47            762                     1           80               0   \n",
       "3      43             69                     1           64               0   \n",
       "4      37            396                     2          105               0   \n",
       "...   ...            ...                   ...          ...             ...   \n",
       "9985   39            226                     5           76               0   \n",
       "9986   55            424                     1           86               0   \n",
       "9987   37            623                     2           68               0   \n",
       "9988   22            449                     0           53               0   \n",
       "9989   79            229                     4           86               0   \n",
       "\n",
       "      Technology_4G  Technology_fiber  Technology_landline  Technology_phone  \n",
       "0                 1                 0                    0                 0  \n",
       "1                 0                 0                    0                 1  \n",
       "2                 1                 0                    0                 0  \n",
       "3                 0                 0                    0                 1  \n",
       "4                 0                 1                    0                 0  \n",
       "...             ...               ...                  ...               ...  \n",
       "9985              0                 1                    0                 0  \n",
       "9986              0                 0                    0                 1  \n",
       "9987              1                 0                    0                 0  \n",
       "9988              0                 0                    1                 0  \n",
       "9989              0                 0                    0                 1  \n",
       "\n",
       "[9990 rows x 9 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "57ab4f17",
   "metadata": {},
   "outputs": [],
   "source": [
    "x=df[['Age', 'CustomerSince', 'SupportCallsLastYear', 'AverageBill','Technology_4G', 'Technology_fiber',\n",
    "       'Technology_landline', 'Technology_phone']].values\n",
    "y=df['ChurnIndicator'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "f79fa6f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n",
    "model=RandomForestClassifier(n_estimators=10,max_depth=2, random_state=1234)\n",
    "model.fit(X_train, y_train)\n",
    "y_pred = model.predict(X_test)\n",
    "f1_score(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "008bab1b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.15873015873015872"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n",
    "model=RandomForestClassifier(n_estimators=10,max_depth=2, random_state=1234,class_weight='balanced')\n",
    "model.fit(X_train, y_train)\n",
    "y_pred = model.predict(X_test)\n",
    "f1_score(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "03002fa1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
